Track a laptop IP with BASH

Standard

Use
http://ifconfig.me/all/json
https://github.com/dominictarr/JSON.sh


Or you can use this.

559 total views, no views today

Encrypting and Compiling BASH code

Standard

If you are looking to protect your BASH script from prying eyes, try encrypting it and then compiling it.

1st: Encrypting
1] obfsh – You will want this tool from http://www.comp.eonworks.com/scripts/obfuscate_shell_script-20011012.html
obfsh is quite flexible and can obfuscate any type of shell script. The
obfuscated script version is printed to stdo. The original script is not
modified.

Using obfsh options cleverly, one may fool more then just a casual intruder
or snooper, and certainly make understanding of the obfuscated script harder
and more time consuming.

Read some of the options first.

You can vary the way it works.

So to encrypt it, take this tool and make your script hard to read.

2] ?(Another method is out there. Just have to find it again.)

2nd: Compile
Take your newly encrypted file from step 1 and use it here with the tool called shc.

Check your distro or goto http://www.datsi.fi.upm.es/~frosal/ and download shc (shc-3.8.9.tgz version of this posting).
Edit: After trying to get this to work smoothly, and failing to get “make” to work, I then tested version 3.8.7. This one ran “make” correctly and “make install”. I suggest using it instead. http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz

Use -r, this will relax security to create a redistributable binary that executes on other systems that runs the same operating system as the one on which it was compiled.

3rd (optional): Specifying Expiration Date for Your Shell Script
This makes it so the compiled bash script will not run after the set date and will display a message instead.

Note:
If you get the following error messages upon give the shc command:

then install the following packages:

Last but not the least. There is no guarantee that this utility will provide you a very strong security protection. Experienced users or hackers who have sufficient knowledge about “gdb” or other debugger tools can decrypt your shell script(when using shc alone). Although it does provide a good starting point to encrypt (hide) shell scripts from “regular” users if you are a system administrator.

5,818 total views, 2 views today

BASH script based Matrix effect. Use it in .screenrc

Standard
BASH Matrix effects
BASH Matrix effects
matrix (1).tar.gz
1.1 KiB
464 Downloads
Details...

The paths are needing adjusted to work for your placement.
Two places to change. Number one is the matrix.sh file. You will see it below.
Number two is the matrix_char.sh file. The very first part.
Continue reading

1,339 total views, 1 views today

Scripts to find and verify SSH logins to other machines by hacking back via Kippo

Standard

First we log all the connection attempts to my server(Live or new Virtual Machine) using the package called Kippo – http://code.google.com/p/kippo/.


Then we create this file I called grab_ssh_info.sh(Click for latest).

# Only read todays and loop each line in the string
grep -i $todays_date /home/ris/kippo-0.5/log/kippo.log | while read -r line; do

# Only read the lines that contain login auths and IPs. All in one line in this case.
if [[

]]; then
# Cut out the different parts.
inIP=

inUSER=

inPASS=

# Throw it all in together for outputing to a log of my own.
output=”$inIP|$inUSER|$inPASS”
#echo $output

# IF we do not already have it in the log, append the info to it.
if [ ! -e /root/scripts/kippo_ssh_auths.log ]; then
touch /root/scripts/kippo_ssh_auths.log
fi

grep -q “$output” /root/scripts/kippo_ssh_auths.log
if [ $? == 1 ]; then
echo “$inIP|$inUSER|$inPASS” >> /root/scripts/kippo_ssh_auths.log
fi
fi
done
[/crayon]


Then we can use the copy of /root/kippo_ssh_auths.log log to try and connect BACK to the door knockers machine and see if the login works.
If it does, add it to a success log(if new) and go on to the next one.
If it fails, ignore it. It will be deleted when we delete the copy of the log file at the end of the script.
I call this file test_ssh_info.sh


Small script(start_kippo.sh) for cron to make sure your Kippo is still running.
I noticed that the small VPS I was running would kill Kippo once awhile because I ran out of memory(32MB) and swap(32MB). So I tested every minute to see if needed starting again.


Set your log rotation to cycle the Kippo log every 24 hours or my scripts will be re testing a lot of ssh connections.
Set your cron to run them whenever. I recommend just before the logrotate cycle. Just make sure it is sequenced right. Do the grab script first.

1,169 total views, no views today

Kippo scripts

Standard

This is to gather the IP addresses and the USERNAME and PASSWORDS that were used in the attempts to login to my machines.

# Only read todays and loop each line in the string
grep -i $todays_date /home/kris/kippo-0.5/log/kippo.log | while read -r line; do

# Only read the lines that contain login auths and IPs. All in one line in this case.
if [[

]]; then
# Cut out the different parts.
inIP=

inUSER=

inPASS=

# Throw it all in together for outputing to a log of my own.
output=”$inIP|$inUSER|$inPASS”
echo $output

# IF we do not already have it in the log, append the info to it.
if [ !

]; then
echo “$inIP|$inUSER|$inPASS” >> /root/kippo_ssh_auths.log
fi
fi
done
[/crayon]


595 total views, no views today