Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - hakerdefo

Pages: [1] 2 3 ... 32
1
Scripts / Re: sl - A better ls
« on: Today at 07:54:09 PM »
It happens  :D

And here is some bonus for the fans of aliases  8)
VastOne is one of them  ;)

Code: [Select]
alias cd='builtin cd "$@"; sl'

Cheers!!!

2
Scripts / Re: sl - A better ls
« on: Today at 07:16:49 PM »
Nicely spotted Vasty  8)
By default 'sl' let the hidden files remain, well err, hidden  :D
This is to avoid cluttering the output.

However one can easily override this to view the hidden files. Just add the following to the config file '.sl.tcl'
Code: [Select]
set SWITCH(ignore) 1

I've added this info to the original post.

Cheers!!!

3
Scripts / sl - A better ls
« on: Today at 06:22:35 PM »
We being the terminal junkies use cli environment as much as possible and 'ls' is one of the essential tool we use to list files and directories.
Now here comes 'sl'. I call it a better ls. It's a simple script so nothing to install. Just Download sl and save it somewhere in your $PATH. Also Download sl.tcl, a sample configuration file, and save it with the name '.sl.tcl' in your $HOME directory.

To view the hidden files you'll need to add the following line to the config file '.sl.tcl'
Code: [Select]
set SWITCH(ignore) 1

And yes 'sl' has a single dependency that you can easily install like this,

Code: [Select]
sudo apt-get install tcl

That's it! Next time you want to use 'ls' just do 'sl' and I'm confident you'll love it  8)

The original intent of this post is to serve as the place-holder of this wonderful script as the original website is gone!

Cheers!!!

4
That's great  :)

Cheers!!!

5
Add following to your .bashrc,

Code: [Select]
GO2TMP=~/.go2/tmp
go2 () {
    /usr/lib/go2/go2.py $*;
    if [ -e $GO2TMP ]; then
cd "$(cat $GO2TMP)"
rm $GO2TMP > /dev/null
    fi
}

Save the file and run,

Code: [Select]
source $HOME/.bashrc

Try go2.

Cheers!!!

6
Great! Thanks!

Cheers!!!

7
Yeah.. pretty sure I will not have to worry there..

Thanks!

I don't use "Go" myself so the alias works fine for me too. It removes an extra key press  ;)

Cheers!!!

8
Aye that works fine..

Thanks!

Great!!! Thanks for the testing work!!!
I'll update the script with an option to add website(s) to the white-list  8)

Cheers!!!

9
Any known reason why creating an alias

Code: [Select]
alias go='go2'
would be a bad idea?  Thinking in terms of scripts or any other need for 'go'

If someone is using Go, then it might not be a great idea  :-\

Cheers!!!

10
It's so addictive you might stop using good old "cd"  8)

Cheers!!!

11
Hi there Vasty,
Open /etc/hosts.allow file and add,

Code: [Select]
ALL: .foobar.com

Where ".foobar.com" is the site that you want to allow (weather tab site for example). Save the file. Clear your browser's cache and try to open that site. Does this work? If it does then I'll add option to white-list sites in the script.

Cheers!!!

12
How To's / How to easily and quickly change directories in terminal
« on: March 25, 2017, 08:48:55 PM »
Okay, most of us spent quite a bit of time in a terminal window, right?
Now navigating between directories in terminal can be cumbersome sometimes.

For example you want to navigate to the "Terminator" directory,
Code: [Select]
~/Downloads/Videos/Movies/Action/Terminator/
You will have to enter,
Code: [Select]
cd Downloads/Videos/Movies/Action/Terminator/

I know you can use Tab-completion but even with it you'll agree there are plenty of key-presses involved here.

Okay, now assume you are in the "Terminator" directory and you want to go back to the "Videos" directory. You'll have to do,
Code: [Select]
cd "../ ../"

See, it's cumbersome! Here is the easiest and smartest method to change directories in terminal.

First we need to install a tiny application,
Code: [Select]
sudo apt-get install go2

After the installation has completed, in your terminal run,
Code: [Select]
go2; source $HOME/.bashrc

That's it! Now you can navigate to "Terminator" directory easily like this,
Code: [Select]
go2 Terminator

Or if you are in a hurry,
Code: [Select]
Go2 Term

And from "Terminator" directory going back to the "Videos" directory is just as easy,
Code: [Select]
go2 Videos

If in hurry,
Code: [Select]
go2 Vid

Now if you have two directories "Downloads" and "Documents" and you do,
Code: [Select]
go2 Do
go2 will prompt you to select one of them,
Code: [Select]
a: ~/Documents
b: ~/Downloads
If you want to select "Documents" you need to enter "a" and for selecting "Downloads" you enter "b". Simple!!!

For more info,
Code: [Select]
man go2

Cheers!!!

13
Going to give this a thorough testing tonight
Did it work for you?!?
Any bug, idea, suggestion?

Cheers!!!

14
Bacon Kills!   ::)  I'm sure that bacon is what caused both my heart attacks!   ???

ROFL  :D  :D  :D

15
Okay here is something for those of you who hates internet ads and at the same time are not big fans of add-ons and  extensions.
This is a complete rewrite of one of my earlier ad-block script.

Save pmiab somewhere in your $PATH with 755 permission and run it with sudo permissions.

Code: [Select]
sudo pmiab

And select following from the menu,
Code: [Select]
Block Internet Adverts

You can easily disable ad-blocking (also read replace the original hosts) by selecting,
Code: [Select]
Unblock Internet Adverts

If a browser is open then clear its cache and restart it. Enjoy the internet on any and every browser without those irritating ads  8)

Code: [Select]
#!/usr/bin/env bash
########
function byye (){
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "One man's advertising is another man's malware"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  sleep 1
  tput sgr0
  printf "\033c"
  exit 0
}
########
function pm_unblock (){
  pmcp=$(which cp)
  pmrm=$(which rm)
  if [ ! -f /etc/hosts-block ]; then
    printf "\033c"
    echo ""
    { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
    echo ""
    echo -e '\e[38;5;82m' "Ad-blocking hosts not in use! Nothing to unblock!"
    echo ""
    { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
    echo ""
    echo ""
    read -r -s -p $'Press Any Key To Return To Main Menu...\n' -n1
    starrt
  fi
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "Replacing the original hosts file..."
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  sleep 1
  "$pmcp" /etc/hosts-system /etc/hosts
  chmod 644 /etc/hosts
  "$pmrm" -f /etc/hosts-system
  "$pmrm" -f /etc/hosts-block
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "All done!!! Original system hosts file restored!!!"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo ""
  read -r -s -p $'Press Any Key To Return To Main Menu...\n' -n1
  starrt
}
########
function pm_block (){
  pmcp=$(which cp)
  hosts_cooking=$(mktemp)
  hosts_cooked=$(mktemp)
  datum=$(date +%d-%m-%Y:%H:%M:%S)
  pmrm=$(which rm)
  if [ ! -f /etc/hosts-system ]; then
    "$pmcp" /etc/hosts /etc/hosts-system
    chmod 444 /etc/hosts-system
  fi
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "Downloading ad-blocking hosts files..."
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  wget -nv -O - "http://winhelp2002.mvps.org/hosts.txt" >> "$hosts_cooking" || { "$pmrm" -f "$hosts_cooking"; "$pmrm" -f "$hosts_cooked"; printf "\033c"; echo ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo ""; echo -e '\e[38;5;82m' "OOPS!! Failed to download \"mvps\" hosts file!!"; echo -e '\e[38;5;82m' "Make sure your internet connection is active!"; echo -e '\e[38;5;82m' "If the problem persists you can report it at,"; echo -e '\e[38;5;82m' "GitHub repository of the project by creating,"; echo -e '\e[38;5;82m' "an issue there. Here is the link to the repo,"; echo ""; echo -e '\e[38;5;82m' "https://github.com/hakerdefo/pmiab"; echo ""; echo -e '\e[38;5;82m' "If you don't use GitHub you can report it by,"; echo -e '\e[38;5;82m' "emailing the author at the following address,"; echo ""; echo -e '\e[38;5;82m' "hakerdefo (at) gmail (dot) com"; echo ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo ""; tput sgr0; exit 1; }
  wget -nv -O - "http://hosts-file.net/ad_servers.asp" >> "$hosts_cooking" || { "$pmrm" -f "$hosts_cooking"; "$pmrm" -f "$hosts_cooked"; printf "\033c"; echo ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo ""; echo -e '\e[38;5;82m' "OOPS!! Failed to download \"hpHo\" hosts file!!"; echo -e '\e[38;5;82m' "Make sure your internet connection is active!"; echo -e '\e[38;5;82m' "If the problem persists you can report it at,"; echo -e '\e[38;5;82m' "GitHub repository of the project by creating,"; echo -e '\e[38;5;82m' "an issue there. Here is the link to the repo,"; echo ""; echo -e '\e[38;5;82m' "https://github.com/hakerdefo/pmiab"; echo ""; echo -e '\e[38;5;82m' "If you don't use GitHub you can report it by,"; echo -e '\e[38;5;82m' "emailing the author at the following address,"; echo ""; echo -e '\e[38;5;82m' "hakerdefo (at) gmail (dot) com"; echo ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo ""; tput sgr0; exit 1; }
  wget -nv -O - "http://someonewhocares.org/hosts/hosts" >> "$hosts_cooking" || { "$pmrm" -f "$hosts_cooking"; "$pmrm" -f "$hosts_cooked"; printf "\033c"; echo ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo ""; echo -e '\e[38;5;82m' "OOPS!! Failed to download \"sowc\" hosts file!!"; echo -e '\e[38;5;82m' "Make sure your internet connection is active!"; echo -e '\e[38;5;82m' "If the problem persists you can report it at,"; echo -e '\e[38;5;82m' "GitHub repository of the project by creating,"; echo -e '\e[38;5;82m' "an issue there. Here is the link to the repo,"; echo ""; echo -e '\e[38;5;82m' "https://github.com/hakerdefo/pmiab"; echo ""; echo -e '\e[38;5;82m' "If you don't use GitHub you can report it by,"; echo -e '\e[38;5;82m' "emailing the author at the following address,"; echo ""; echo -e '\e[38;5;82m' "hakerdefo (at) gmail (dot) com"; echo ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo ""; tput sgr0; exit 1; }
  wget -nv -O - "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext" >> "$hosts_cooking" || { "$pmrm" -f "$hosts_cooking"; "$pmrm" -f "$hosts_cooked"; printf "\033c"; echo ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo ""; echo -e '\e[38;5;82m' "OOPS!! Failed to download \"yoyo\" hosts file!!"; echo -e '\e[38;5;82m' "Make sure your internet connection is active!"; echo -e '\e[38;5;82m' "If the problem persists you can report it at,"; echo -e '\e[38;5;82m' "GitHub repository of the project by creating,"; echo -e '\e[38;5;82m' "an issue there. Here is the link to the repo,"; echo ""; echo -e '\e[38;5;82m' "https://github.com/hakerdefo/pmiab"; echo ""; echo -e '\e[38;5;82m' "If you don't use GitHub you can report it by,"; echo -e '\e[38;5;82m' "emailing the author at the following address,"; echo ""; echo -e '\e[38;5;82m' "hakerdefo (at) gmail (dot) com"; echo ""; for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; echo ""; tput sgr0; exit 1; }
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "Parsing, Cleaning, De-Duplicating, Sorting..."
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  sleep 1
  sed -e 's/\r//' -e '/^127.0.0.1/!d' -e '/localhost/d' -e 's/127.0.0.1/0.0.0.0/' -e 's/ \+/\t/' -e 's/#.*$//' -e 's/[ \t]*$//' < "$hosts_cooking" | sort -u > "$hosts_cooked"
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "Merging ad-blocking hosts with original system hosts..."
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  sleep 1
  echo -e "\n# Ad blocking list generated on $datum" | cat /etc/hosts-system - "$hosts_cooked" > /etc/hosts-block
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "Doing some clean-up..."
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  sleep 1
  "$pmrm" -f "$hosts_cooking"
  "$pmrm" -f "$hosts_cooked"
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "Installing pmiab generated hosts file..."
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  sleep 1
  "$pmcp" /etc/hosts-block /etc/hosts
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "All done!!! Enjoy the internet without those pesky adverts!!!"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo ""
  read -r -s -p $'Press Any Key To Return To Main Menu\n' -n1
  starrt
}
########
function pm_netchk (){
  wget --spider --user-agent="Mozilla/5.0 Gecko/20100101" --timeout=30 -q "www.google.com" -O /dev/null
  RETVAL=$?
  case "$RETVAL" in
    0)
      pm_block
      ;;
    *)
      printf "\033c"
      echo ""
      { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
      echo ""
      echo -e '\e[38;5;82m' "No active internet connection available!!"
      echo -e '\e[38;5;82m' "Please check your internet connectivity!!"
      echo -e '\e[38;5;82m' "Active internet connection is required to"
      echo -e '\e[38;5;82m' "download necessary adblocking hosts files"
      echo ""
      echo ""
      read -r -s -p $'Press Any Key To Return To Main Menu\n' -n1
      starrt
      ;;
  esac
}
########
function starrt (){
  if [ "$EUID" -ne 0 ]; then
    printf "\033c"
    echo ""
    { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
    echo ""
    echo -e '\e[38;5;82m' "You must run \"pmiab\" script using \"sudo\" or as the root user."
    echo -e '\e[38;5;82m' "Hint : \"sudo pmiab\" or \"su -c 'pmiab'\""
    echo ""
    { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
    echo ""
    tput sgr0
    exit 1
  fi
  printf "\033c"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo -e '\e[38;5;82m' "pmiab - (Poor Man's Internet Ad Blocker) blocks ads system-wide"
  echo ""
  { for i in {16..51} {51..16}; do echo -en "\e[38;5;${i}m#\e[0m"; done; echo; }
  echo ""
  echo ""
  echo -e '\e[38;5;82m' "01 Block Internet Adverts"
  echo -e '\e[38;5;82m' "02 Unblock Internet Adverts"
  echo -e '\e[38;5;82m' "03 Quit pmiab"
  echo -e ""
  echo -e ""
  echo -e '\e[38;5;82m' "Enter Your Choice: "
  echo -e ""
  read -r Choice
  case $Choice in
    01 | 1)
      pm_netchk
      ;;
    02 | 2)
      pm_unblock
      ;;
    03 | 3)
      byye
      ;;
    *)
      printf "\033c"
      echo -e ""
      echo -e ""
      echo -e '\e[38;5;82m' "\"$Choice\" Is An Invalid Option!"
      echo -e ""
      echo -e '\e[38;5;82m' "Correct Options To Choose From Are 1-2-3"
      echo -e ""
      echo -e '\e[38;5;82m' "To block internet adverts press \"1\" & hit \"Enter\" key"
      echo -e '\e[38;5;82m' "To restore original hosts press \"2\" & hit \"Enter\" key"
      echo -e '\e[38;5;82m' "To exit from pmiab script press \"3\" & hit \"Enter\" key"
      echo -e '\e[38;5;82m' "Got It?!? Ready To Give It Another Go?!?"
      echo -e ""
      read -r -s -p $'Press Any Key To Try Again...\n' -n1
      starrt
      ;;
  esac
}
########
while :
do
  starrt
done


Cheers!!!

Pages: [1] 2 3 ... 32