Black Asylum

Network and System Security (or lack thereof)

Browsing Posts in one-liner

# Grab a given HTTP/HTTPS page from a target website
perl -e 'print "GET / HTTP/1.0\r\n\r\n"' | nc <SYSTEM IP> 80
perl -e 'print "GET / HTTP/1.0\r\n\r\n"' | openssl s_client -connect <SYSTEM IP>:443 -quiet

# Grab SNMP "system" data from target
snmpwalk -v 2c -c public <SYSTEM IP> .1.3.6.1.2.1.1

# List all rpc services offered by target
rpcinfo -p <SYSTEM IP>

# NetBIOS name table for one target
nmblookup -A <SYSTEM IP>

# NetBIOS name table for an entire range of targets
nbtscan <NETWORK>/<CIDR>

# Display Shares and other information for target
smbclient -N -L <SYSTEM IP>
smbclient -A creds.txt -L <SYSTEM IP>
     creds.txt:
          username = <USER NAME>
          password = <USER PASSWORD>
          domain   = <DOMAIN>

# Show NFS mount information
showmount -e <SYSTEM IP>
showmount -a <SYSTEM IP>

# Play with open X11 sessions
xlsclients -display <SYSTEM IP>:0.0 -l
xwininfo -display <SYSTEM IP>:0.0 -root
xwininfo -display <SYSTEM IP>:0.0 -id <WINDOW ID>
xwd -display <SYSTEM IP>:0.0 -root -silent - | convert - <SYSTEM IP>.png
xwd -display <SYSTEM IP>:0.0 -id <WINDOW ID> -silent - | convert - <SYSTEM IP>.png

Let’s take a look at the problem of calculating the “md5″ sum of every file in a directory including within subdirectories.

Well, we know the “md5sum” command works fine on a single file or for an entire directory. How about we write a short perl script to recurse every directory & subdirectory from a given starting point issuing the “md5sum” command on any files it encounters…

#!/usr/bin/perl

$startDir = $ARGV[0];

if ($startDir =~ /^$/) {
        $startDir = ".";
}

printDir($startDir);

sub printDir {
        my $baseDir = $_[0];

        if ($baseDir !~ /.*\/$/) {
                $baseDir = $baseDir . "/";
        }

        my @files = glob($baseDir . "*");

        foreach $file (@files) {
                if (-f $file) {
                        `md5sum $file >> /tmp/md5`;
                } else {
                        printDir($file);
                }
        }
}

Well, that does work and did not take too long to write, but we could have done it much simpler…

How about we let a system tool build a list of all files (and recurse subdirectories) then we use that file as an input file for md5sum…

find . > files.md5
md5sum -c files.md5

Okay, so that works as well and is much shorter than the script. But I think we can do it in one line…

find . ! -type d -print0 | xargs -0 md5sum

There we go, that works nicely.

Can you do better? let me know.

Click HERE

or goto Google and type:

inurl:(service|authors|administrators|users) ext:pwd “# -FrontPage-”