• # smtp commands
    • HELO sendinghostname
      • This command initiates the SMTP conversation. The host connecting to the remote SMTP server
      • identifies itself by it's fully qualified DNS host name.
    • EHLO sendinghostname
      • An alternative command for starting the conversation. This states that the sending server
      • wants to use the extended SMTP (ESMTP) protocol.
    • MAIL From:
      • This is the start of an email message. The source email address is what will appear in the
      • "From:" field of the message.
    • RCPT To:
      • This identifies the receipient of the email message. This command can be repeated multiple times
      • for a given message in order to deliver a single message to multiple receipients.
    • DATA
      • This command signifies that a stream of data, ie the email message body, will follow.
      • The stream of data is terminated by a "." on a line by itself.v
    • RSET
      • Abort the current e-mail transaction (reset), but stay connected for more to come.
    • NOOP
      • No op,. as in .no operation.. Do nothing, but return an .OK. response.
    • QUIT
      • This terminates an SMTP connection. Multiple email messages can be transfered during a single TCP/IP connection.
      • This allows for more efficient transfer of email. To start another email message in the same session,
      • simply issue another "MAIL" command.
    • VRFY username
      • This command will request that the receiving SMTP server verify that a given email username is valid.
      • The SMTP server will reply with the login name of the user. This feature can be turned off in sendmail because
      • allowing it can be a security hole. VRFY commands can be used to probe for login names on a system.
    • EXPN aliasname
  • EXPN is similar to VRFY, except that when used with a distribution list, it will list all users on that list.
  • This can be a bigger problem than the "VRFY" command since sites often have an alias such as "all".
  • Subject:
  • Cc:
  • Reply-To:
  • Custom Headers:
    • # Client sends headers
    • From: Foo
    • To: Bar
    • Date: Mon, 1 May 2006 10:23:00 +0000 (UTC)
    • Reply-To:
    • # Custom header
    • X-submission: Submitted by 192.0.20.1
    • Subject: This is my message
    • Email header lines are not SMTP commands per se. They are sent in the DATA stream for a message.
    • Header lines appear on a line by themselves, and are seperated from the body of a message by a blank line.
    • # find command
      • find -mmin -10
        • find files changed in the last 10 minutes
      • find -size +5M -ls
        • find files larger then 5 Meg. display with extra proprties, not just a listing
      • Find / replace strings in multiple files
        • find /path/to/files -type f -exec sed -i 's/old.string/new.string/g' {}/;
        • -or-
        • sed -i 's/hello.com/localhost.net/g' /root/test/*
    • watch command. can be used in combination with many others such as FIND (watch file proprties chagne in real time or DF (watch drive Size in real time)
      • watch -n 1 find -mmin -1
        • files that changed in the last minute, refresh every second (the -n option)



    • # GREP - global regular expression print
      • grep ""
        • Search for word in a file
      • grep -n ""
        • Search with line numbers
      • grep -vn ""
        • Priont all but the
      • grep -c ""
        • Print count of an occurance
      • grep -l "boo" *
        • prints only the filenames of files in the query that have lines that match the search string
      • grep -i "BOO"
        • Ignore case
      • grep -x "boo"
        • looks for eXact matches only.
      • grep -f search
        • specify a file containing the search string
      • grep "e$"
        • search the file for lines ending with the letter "e"
      • egrep "boot|boots"
        • egrep supports that grep does not is the pipe (|) funcitons as an "or."
      • find | grep "hello"
        • print out the files that find returns that contain the text "hello"
      • tail -n8 | grep "boo"
        • performs a grep on the last 8 lines of
        • Can be used for live grepping with -f
      • find . -exec grep "boo" {} \;
        • search for the string "boo" in every directory below the current directory
      • grep "\([a-z]\)\1"
        • uses backreferences to find lines that contain two of the same lowercase letter in succession.



    • Disk operations - USB
      • delete partitions and format a USB drive
      • fdisk /dev/sda
        • delete / create partitions
      • mkfs -t vfat /dev/sda1
        • format (in this case as Fat32)
    • # mount USB drive
      • fdisk -l
        • find the name of the device
      • mkdir /mnt/sdb1
        • create mountpoint directory
      • mount -t vfat /dev/sdb1 /mnt/sdb
        • mount device to the mountpoint directory
      • echo "/dev/sdb1 /mnt/sdb1 vfat defaults 0 0" >> /etc/fstab
      • mount -a
        • automate the process (above two lines)



    • Disk operations - Network
      • # mkdir /mnt/sharename
        • create mount point
      • # sudo chmod u+s /sbin/mount.cifs /sbin/umount.cifs
      • # mount.cifs //server.domain/sharename /path/to/mountpoint -o user=myusername,domain=
        • - //server.domain.com/sharename is the mount location. R
        • - /path/to/mountpoint is the location you want to map/mount the network drive at.
        • - username=myusername - myusername should be replaced with your Stevens username.
        • - workgroup=campus - this specifies the domain to check your username and password against, leave it like this
      • # umount.cifs /path/to/mountpoint
        • un-mount



    • encryption with truecrypt
      • # truecrypt -t -c
      • Encrypt a volume
        • follow the steps in wizard
    • mount encrypted volume
      • truecrypt /dev/device-or-file /mnt/mountpoint
        • mount the encrypted volume



    • # CRONTAB
      • Users
      • /usr/lib/cron/cron.allow
      • /usr/lib/cron/cron.deny
    • crontab options/agruments
      • crontab -e Edit your crontab file, or create one if it doesn.t already exist.
      • crontab -l Display your crontab file.
      • crontab -r Remove your crontab file.
      • crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.
    • Scheduling
      • * * * * * command to be executed
      • - - - - -
      • | | | | |
      • | | | | +----- day of week (0 - 6) (Sunday=0)
      • | | | +------- month (1 - 12)
      • | | +--------- day of month (1 - 31)
      • | +----------- hour (0 - 23)
      • +------------- min (0 - 59)
      • Example
        • 30 18 * * * rm /home/someuser/tmp/*
        • will run at 6:30 PM every day
    • Disable Email
      • command At the end of the cron job line
      • /dev/null 2>&1
    • Generate log file
      • 30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log



    • # IF BRidge
      • Creating IF bridge - mainly as a if tap
      • apt-get isntall bridge-utils (or equivalent)
      • brctl add br0 <--create bridge
      • ip addr show <-- check interfaces to be added
      • brctl addif br0 eth0 eth1 (or quivalent) -------- add if's to br0
      • ifconfig br0 up
      • either dhcpcleint br0 -or- assign static IP
      • tcpdump -i br0



    • # iptables
      • add block for specific IP
      • iptables drop
      • add port block
      • iptables block
      • add port allow
      • iptables port allow



    • # swapfile create
      • fallocate -l 1G /swapfile-1 ------ create a swapfile - 1Gb in size
      • chown root:root /swapfile ----- set owner
      • chmod 0600 /swapfile ---------- set proper permissions
      • mkswap /swapfile -------------- make swap file
      • swapon /swapfile -------------- use the file
      • swapon -s -------------------- verify the file
      • /swapfile none swap sw 0 0 -------add this to /etc/fstab



    • # IRDA Utilities
      • Working with IRDAp
      • apt-get install irda-utlis (or equivalent)
      • lsusb <-- check to make sure irda is being detected
      • modprobe irda-usb <-- load usb driver
      • irattach ird0 -s <--- create interface
      • ifconfig br0 up
      • either dhcpcleint br0 -or- assign static IP
      • tcpdump -i br0



    • # Groups Memebership
      • checking group members
      • getent group ;
      • lid -g groupname
      • groupadd "groupname" - add a group
      • useradd -d/home/"user" -g "groupname" -s /bin/bash -M "username"



    • # open ssl commands
      • conversion from pfx to key and crt
      • openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]
      • openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]
      • openssl rsa -in [keyfile-encrypted.key] -out [keyfile-decrypted.key]
      • openssl speed --> test encryption speed
      • openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem --> genrt self-signed
      • openssl enc -base64 -in file.txt -out file.out.enc --> base64 encode a file
      • openssl enc -aes-256-cbc -a -salt -in file.txt -out file.enc --> aes256 encrypt |"-a" create b64 encoded out
      • openssl enc -d -aes-256-cbc -a -in file.enc --> aes 256 decrypt |"-a" reads b64 encoded
      • openssl passwd -salt 8E MySecret --> gen crypt style passwd with salt "8E"
      • openssl passwd -1 -salt sXiKzkus MySecret --> gen shadow style passwd with salt "sXiKzkus"
      • openssl prime 119054759245460753 --> test prime number |"-hex 8E" test number in hex for prime
        • Create Self-Signed cert for HTTPS
          • openssl genrsa -out rootCA.key 2048
          • openssl req -x509 -new -nodes -key rootCA.key -days 365 -out rootCA.crt
          • openssl genrsa -out host.key 2048
          • openssl req -new -key host.key -out host.csr
          • openssl x509 -req -in host.csr -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out host.crt -days 365



    • # netcat
      • Get banner
        • echo -e "GET HTTP/1.0\n" |netcat google.com 443 |grep -i "server:"
        • echo -e "GET HTTP/1.0\n" |stunnel -c -r google.com:443 |grep -i "server:"
      • Port Scanner:
        • nc -v -w 1 localhost -z 1-3000
      • File Transfer
        • Machine B: nc -lp 1337 > file.zip
        • Machine A: nc -w 1 10.48.2.40 1337 < file.zip
      • Chat Server
        • server: nc -lp 1337
        • client: nc 10.48.2.40 1337
      • Telnet Server
        • Linux: nc -lp 1337 -e /bin/bash
        • Windows: nc -lp 1337 -e cmd.exe
      • Spoofing HTTP Headers (always end with a blank line to send the command through)
        • nc google.com 80
          • GET / HTTP/1.1
          • Host: google.com
          • User-Agent: NOT-YOUR-BUSINESS
          • Referrer: YOUR-MOM.COM
          • Range: bytes=0-18446744073709551615 ;)
          • - or -
          • HTTP/1.1 200 OK
          • Cache-Control: private
          • Content-Type: text/html; charset=ISO-8859-1
          • Set-Cookie: PREF=ID=79f8f28c854d90ec:TM=1186369443:LM=1186369443:S=UIiTvi68MtmbcmGl; expires=Sun, 1-Jan-2038 19:14:07 GMT; path=/; domain=.google.com
          • Server: GWS/2.1
          • Transfer-Encoding: chunked
          • Date: Mon, 06 Aug 2007 03:04:03 GMT
      • Web Server
        • while true; do nc -l -p 80 -q 1 < error.html; done
      • Cloning Hard Drive Partitions Over the Network (partitions unmounted)
        • On a system you want to clone do: dd if=/dev/sda | nc 192.168.0.1 9000
        • On the receiving side do: nc -l -p 9000 | dd of=/dev/sda
      • tunnel ports / forward traffic:
        • nc -l 80 | nc newserver.domain.tld 8080



    • # Somewhat obscure UNIX commands
      • column: create columns from text input
      • tr: substitute/delete input
      • join: like a database join but for text
      • comm: file comparison like a db join
      • paste: put lines in a file next to each other
      • rs: reshape arrays
      • jot: generate data
      • expand: replace spaces and/or tabs
      • time: track how long a task takes to run
      • watch: execute something on a schedule in realtime
      • xargs: execute something on all inputs
      • iftop: visually show network traffic
      • htop: show system stats more powerfully
      • xxd: manipulate files in hex
      • mtr: powerful traceroute replacement
      • mdfind: osx find replacement that uses spotlight
      • brew: osx package manager
      • df: disk usage
      • du: disk usage
      • dig: dns queries
      • host: dns queries
      • man ascii: lookup your ascii
      • sshfs: mount a directory through ssh
      • wget: get w’s
      • tmux: a better screen
      • pushd: push your pwd to a stack
      • popd: pop pwd off your stack
      • lsof: godlike
      • ncat: use this instead of nc
      • fuser: kills locking processes
      • vim: attack yourself
      • rename: change spaces to underscores in names
      • open .: in osx, open finder in the current dir
      • lsmod: show kernel modules
      • timeout: execute something and kill it soon after
      • disown: protect a job from disconnect
      • fc: edit your last command in your editor and execute it
      • sudo !!: repeat last command with sudo
      • tee: send output to stdout as well
      • pgrep: greps through processes
      • pkill: kills processes based on search
      • fmt: text formatter
      • apropos: info on commands
      • strace: the uber debug tool
      • man units: interesting
      • pstree: shows processes in a…well…tree
      • ddate: wtf
      • zgrep: grep within compressed files
      • zless: look at compressed files
      • readlink: read values of links
      • atop: another top
      • split: break a file into pieces
      • dd: disk writing
      • ndiff: show differences in mmap scans
      • ss: show apps using the internet
      • Many thanks to those who have shared
    # BACK TO THE TOP