Advertisement
joemccray

2020 Intro to Linux & Comptia Linux+ Exam Prep

Oct 21st, 2019
1,278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #############################
  2. ############################## # Day 1: Linux Fundamentals # ##############################
  3. #############################
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. #####################################################
  13. # 2020 Intro to Linux & Comptia Linux+ Exam Prep #
  14. # By Joe McCray #
  15. #####################################################
  16.  
  17. - Here is a good set of slides for getting started with Linux:
  18. http://www.slideshare.net/olafusimichael/linux-training-24086319
  19.  
  20.  
  21. - Here is a good tutorial that you should complete before doing the labs below:
  22. http://linuxsurvival.com/linux-tutorial-introduction/
  23.  
  24.  
  25. - I prefer to use Putty to SSH into my Linux host.
  26. - You can download Putty from here:
  27. - http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
  28.  
  29. Here is the information to put into putty
  30.  
  31. Host Name: 149.28.201.171
  32. protocol: ssh
  33. port: 22
  34. username: linuxtraining
  35. password: linux!training123!
  36.  
  37.  
  38. ########################
  39. # Basic Linux Commands #
  40. ########################
  41.  
  42. ---------------------------Type This-----------------------------------
  43. cd ~
  44.  
  45. pwd
  46.  
  47. whereis pwd
  48.  
  49. which pwd
  50.  
  51. sudo find / -name pwd
  52.  
  53. /bin/pwd
  54.  
  55. cd ~/students/
  56.  
  57. mkdir yourname <---- replace 'yourname' with your first name in lowercase with no spaces or special characters please
  58.  
  59. cd yourname <---- replace 'yourname' with your first name in lowercase with no spaces or special characters please
  60.  
  61. touch one two three
  62.  
  63. ls -l t (without pressing the Enter key, press the Tab key twice. What happens?)
  64.  
  65. h (and again without pressing the Enter key, press the Tab key twice. What happens?)
  66.  
  67. Press the 'Up arrow key' (What happens?)
  68.  
  69. Press 'Ctrl-A' (What happens?)
  70.  
  71. ls
  72.  
  73. clear (What happens?)
  74.  
  75. echo one > one
  76.  
  77. cat one (What happens?)
  78.  
  79. man cat (What happens?)
  80. q
  81.  
  82. cat two
  83.  
  84. cat one > two
  85.  
  86. cat two
  87.  
  88. cat one two > three
  89.  
  90. cat three
  91.  
  92. echo four >> three
  93.  
  94. cat three (What happens?)
  95.  
  96. wc -l three
  97.  
  98. man wc
  99. q
  100.  
  101. info wc
  102. q
  103.  
  104. cat three | grep four
  105.  
  106. cat three | grep one
  107.  
  108. man grep
  109. q
  110.  
  111.  
  112. man ps
  113. q
  114.  
  115. ps
  116.  
  117. ps aux
  118.  
  119. ps aux | less
  120.  
  121. Press the 'Up arrow key' (What happens?)
  122.  
  123. Press the 'Down arrow key' (What happens?)
  124. q
  125.  
  126. top
  127. q
  128. -----------------------------------------------------------------------
  129.  
  130.  
  131. #########
  132. # Files #
  133. #########
  134. ---------------------------Type This-----------------------------------
  135. cd ~
  136.  
  137. pwd
  138.  
  139. cd ~/students/yourname/
  140.  
  141. pwd
  142.  
  143. ls
  144.  
  145. mkdir LinuxBasics
  146.  
  147. cd LinuxBasics
  148.  
  149. pwd
  150.  
  151. ls
  152.  
  153. mkdir files
  154.  
  155. touch one two three
  156.  
  157. cp one files/
  158.  
  159. ls files/
  160.  
  161. cd files/
  162.  
  163. cp ../two .
  164.  
  165. ls
  166.  
  167. cp ../three .
  168.  
  169. ls
  170.  
  171. tar cvf files.tar *
  172.  
  173. ls
  174.  
  175. gzip files.tar
  176.  
  177. ls
  178.  
  179. rm -rf one two three
  180.  
  181. ls
  182.  
  183. tar -zxvf files.tar.gz
  184.  
  185. rm -rf files.tar.gz
  186.  
  187. zip data *
  188.  
  189. unzip -l data.zip
  190.  
  191. mkdir /tmp/yourname/
  192.  
  193. unzip data.zip -d /tmp/yourname/
  194. -----------------------------------------------------------------------
  195.  
  196.  
  197.  
  198. ############
  199. # VIM Demo #
  200. ############
  201. ---------------------------Type This-----------------------------------
  202. cd ~/students/yourname/LinuxBasics
  203.  
  204. mkdir vimlesson
  205.  
  206. cd vimlesson
  207.  
  208. vi lesson1.sh
  209.  
  210. i (press "i" to get into INSERT mode and then paste in the lines below)
  211.  
  212. #!/bin/bash
  213.  
  214. echo "This is my first time using vi to create a shell script"
  215. echo " "
  216. echo " "
  217. echo " "
  218. sleep 5
  219. echo "Ok, now let's clear the screen"
  220. sleep 3
  221. clear
  222.  
  223.  
  224. ---------------don't put this line in your script----------------------------
  225.  
  226. ESC (press the ESC key to get you out of INSERT mode)
  227.  
  228. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  229.  
  230.  
  231. wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
  232.  
  233.  
  234.  
  235. vi lesson1.sh
  236.  
  237. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  238.  
  239. set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
  240.  
  241. wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
  242.  
  243.  
  244.  
  245.  
  246. vi lesson1.sh
  247.  
  248. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  249.  
  250. set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
  251.  
  252.  
  253. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  254.  
  255. /echo (typing "/echo" immediately after SHIFT: will search the file for the word echo).
  256.  
  257. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  258.  
  259. wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
  260.  
  261.  
  262.  
  263.  
  264. vi lesson1.sh
  265.  
  266. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  267.  
  268. set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
  269.  
  270.  
  271. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  272.  
  273. 4 (typing "4" immediately after SHIFT: will take you to line number 4).
  274.  
  275. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  276.  
  277. wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
  278.  
  279.  
  280.  
  281.  
  282. vi lesson1.sh
  283.  
  284. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  285.  
  286. set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
  287.  
  288.  
  289. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  290.  
  291. 4 (typing "4" immediately after SHIFT: will take you to line number 4).
  292.  
  293. dd (typing "dd" will delete the line that you are on)
  294.  
  295. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  296.  
  297. wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
  298.  
  299.  
  300.  
  301.  
  302. vi lesson1.sh
  303.  
  304. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  305.  
  306. set number (typing "set number" immediately after SHIFT: will add line numbers to vim).
  307.  
  308.  
  309. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  310.  
  311. 4 (typing "4" immediately after SHIFT: will take you to line number 4).
  312.  
  313. dd (typing "dd" will delete the line that you are on)
  314.  
  315. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  316.  
  317. syntax on (typing "syntax on" immediately after SHIFT: will turn on syntax highlighting
  318.  
  319. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  320.  
  321. set tabstop=5 (typing "set tabstop=5" immediately after SHIFT: will set your tabs to 5 spaces
  322.  
  323. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  324.  
  325. wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
  326.  
  327.  
  328.  
  329.  
  330. vi .vimrc
  331. i (press "i" to get into INSERT mode and then paste in the lines below)
  332.  
  333.  
  334. set number
  335. syntax on
  336. set tabstop=5
  337.  
  338. ESC (press the ESC key to get you out of INSERT mode)
  339.  
  340. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  341.  
  342. wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349. vi lesson1.sh
  350.  
  351. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  352.  
  353. echo $MYVIMRC (typing "echo $MYVIMRC" immediately after SHIFT: will display the path to your new .vimrc file
  354.  
  355. [SHIFT+:] (press SHIFT and the : keys at the same time and you should see a : in the bottom left corner of the screen.
  356.  
  357. wq (typing "wq" immediately after SHIFT: will save (w for write, and q for quit meaning exit vim).
  358. -----------------------------------------------------------------------
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367. ###############
  368. # Permissions #
  369. ###############
  370. ---------------------------Type This-----------------------------------
  371. cd ~/students/yourname/LinuxBasics
  372.  
  373. ls -l one
  374. -----------------------------------------------------------------------
  375. We can determine a lot from examining the results of this command. The file "one" is owned by user "me".
  376. Now "me" has the right to read and write this file.
  377. The file is owned by the group "me". Members of the group "me" can also read and write this file.
  378. Everybody else can read this file
  379.  
  380.  
  381. ---------------------------Type This-----------------------------------
  382. ls -l /bin/bash
  383. -----------------------------------------------------------------------
  384.  
  385. Here we can see:
  386.  
  387. The file "/bin/bash" is owned by user "root". The superuser has the right to read, write, and execute this file.
  388. The file is owned by the group "root". Members of the group "root" can also read and execute this file. Everybody else can read and execute this file
  389.  
  390.  
  391. The next command you need to know is "chmod"
  392. rwx rwx rwx = 111 111 111
  393. rw- rw- rw- = 110 110 110
  394. rwx --- --- = 111 000 000
  395.  
  396. and so on...
  397.  
  398. rwx = 111 in binary = 7
  399. rw- = 110 in binary = 6
  400. r-x = 101 in binary = 5
  401. r-- = 100 in binary = 4
  402.  
  403.  
  404. ---------------------------Type This-----------------------------------
  405. ls -l one
  406.  
  407. chmod 600 one
  408.  
  409. ls -l one
  410.  
  411. sudo useradd yourname
  412. aegisweaponssystem
  413.  
  414.  
  415. sudo passwd yourname
  416.  
  417. P@$$w0rd321
  418. P@$$w0rd321
  419.  
  420. sudo chown testuser one
  421. aegisweaponssystem
  422.  
  423. ls -l one
  424.  
  425. sudo chgrp testuser one
  426. aegisweaponssystem
  427.  
  428. ls -l one
  429.  
  430. id
  431.  
  432. su testuser
  433. P@$$w0rd321
  434. -----------------------------------------------------------------------
  435.  
  436. Here is a table of numbers that covers all the common settings. The ones beginning with "7" are used with programs (since they enable execution) and the rest are for other kinds of files.
  437.  
  438. Value Meaning
  439. 777 (rwxrwxrwx) No restrictions on permissions. Anybody may do anything. Generally not a desirable setting.
  440.  
  441. 755 (rwxr-xr-x) The file's owner may read, write, and execute the file. All others may read and execute the file. This setting is common for programs that are used by all users.
  442.  
  443. 700 (rwx------) The file's owner may read, write, and execute the file. Nobody else has any rights. This setting is useful for programs that only the owner may use and must be kept private from others.
  444.  
  445. 666 (rw-rw-rw-) All users may read and write the file.
  446.  
  447. 644 (rw-r--r--) The owner may read and write a file, while all others may only read the file. A common setting for data files that everybody may read, but only the owner may change.
  448.  
  449. 600 (rw-------) The owner may read and write a file. All others have no rights. A common setting for data files that the owner wants to keep private.
  450.  
  451.  
  452.  
  453. Directory permissions
  454. ---------------------
  455. The chmod command can also be used to control the access permissions for directories. In most ways, the permissions scheme for directories works the same way as they do with files. However, the execution permission is used in a different way. It provides control for access to file listing and other things. Here are some useful settings for directories:
  456.  
  457. Value Meaning
  458. 777 (rwxrwxrwx) No restrictions on permissions.
  459. Anybody may list files, create new files in the directory and delete files in the directory.
  460. Generally not a good setting.
  461.  
  462.  
  463.  
  464. 755 (rwxr-xr-x) The directory owner has full access.
  465. All others may list the directory, but cannot create files nor delete them.
  466. This setting is common for directories that you wish to share with other users.
  467.  
  468.  
  469.  
  470. 700 (rwx------) The directory owner has full access. Nobody else has any rights. This setting is useful for directories that only the owner may use and must be kept private from others.
  471.  
  472. ######################
  473. # Process Management #
  474. ######################
  475. ---------------------------Type This-----------------------------------
  476. top
  477. q
  478.  
  479. htop
  480. q
  481.  
  482. ps
  483.  
  484. ps aux
  485.  
  486. ps -A
  487.  
  488. ps -A | less
  489.  
  490. ps axjf
  491.  
  492. pstree
  493.  
  494. pstree -A
  495.  
  496. pgrep bash
  497.  
  498. pgrep init
  499.  
  500. ps aux | grep apache
  501. -----------------------------------------------------------------------
  502.  
  503.  
  504.  
  505. You can list all of the signals that are possible to send with kill by typing:
  506. ---------------------------Type This-----------------------------------
  507. kill -l
  508.  
  509. sudo kill -HUP pid_of_apache
  510.  
  511. The pkill command works in almost exactly the same way as kill, but it operates on a process name instead:
  512.  
  513. pkill -9 ping
  514. The above command is the equivalent of:
  515.  
  516. kill -9 `pgrep ping`
  517. -----------------------------------------------------------------------
  518.  
  519.  
  520.  
  521.  
  522. ################
  523. # Hashing Demo #
  524. ################
  525. ---------------------------Type This-----------------------------------
  526. cd ~/students/yourname/LinuxBasics
  527.  
  528. mkdir hashdemo
  529.  
  530. cd hashdemo
  531.  
  532. echo test > test.txt
  533.  
  534. cat test.txt
  535.  
  536. md5sum test.txt
  537.  
  538. echo hello >> test.txt
  539.  
  540. cat test.txt
  541.  
  542. md5sum test.txt
  543.  
  544. echo test2 > test2.txt
  545.  
  546. cat test2.txt
  547.  
  548. sha256sum test2.txt
  549.  
  550. echo hello >> test2.txt
  551.  
  552. cat test2.txt
  553.  
  554. sha256sum test2.txt
  555.  
  556. cd ..
  557. -----------------------------------------------------------------------
  558.  
  559.  
  560.  
  561. #################################
  562. # Symmetric Key Encryption Demo #
  563. #################################
  564. ---------------------------Type This-----------------------------------
  565. cd ~/students/yourname/LinuxBasics
  566.  
  567. mkdir gpgdemo
  568.  
  569. cd gpgdemo
  570.  
  571. echo test > test.txt
  572.  
  573. cat test.txt
  574.  
  575. gpg -c test.txt
  576. password
  577. password
  578.  
  579. ls | grep test
  580.  
  581. cat test.txt
  582.  
  583. cat test.txt.gpg
  584.  
  585. rm -rf test.txt
  586.  
  587. ls | grep test
  588.  
  589. gpg -o output.txt test.txt.gpg
  590. P@$$w0rD!@#$P@$$w0rD!@#$
  591.  
  592. cat output.txt
  593. -----------------------------------------------------------------------
  594.  
  595.  
  596.  
  597. #########################################################################################################################
  598. # Asymmetric Key Encryption Demo #
  599. # #
  600. # Configure random number generator #
  601. # https://www.howtoforge.com/helping-the-random-number-generator-to-gain-enough-entropy-with-rng-tools-debian-lenny #
  602. #########################################################################################################################
  603. ---------------------------Type This-----------------------------------
  604. cd ~/students/yourname/LinuxBasics/gpgdemo
  605.  
  606. echo hello > file1.txt
  607.  
  608. echo goodbye > file2.txt
  609.  
  610. echo green > file3.txt
  611.  
  612. echo blue > file4.txt
  613.  
  614. tar czf files.tar.gz *.txt
  615.  
  616. gpg --gen-key
  617. 1
  618. 1024
  619. 0
  620. y
  621. John Doe
  622. --blank comment--
  623. O
  624. P@$$w0rD!@#$P@$$w0rD!@#$
  625. P@$$w0rD!@#$P@$$w0rD!@#$
  626.  
  627.  
  628.  
  629. gpg --armor --output file-enc-pubkey.txt --export 'John Doe'
  630.  
  631. cat file-enc-pubkey.txt
  632.  
  633. gpg --armor --output file-enc-privkey.asc --export-secret-keys 'John Doe'
  634.  
  635. cat file-enc-privkey.asc
  636.  
  637. gpg --encrypt --recipient 'John Doe' files.tar.gz
  638.  
  639. rm -rf files.tar.gz *.txt
  640.  
  641. ls
  642.  
  643. tar -zxvf files.tar.gz.gpg
  644.  
  645. gpg --output output.tar.gz --decrypt files.tar.gz.gpg
  646. P@$$w0rD!@#$P@$$w0rD!@#$
  647.  
  648. tar -zxvf output.tar.gz
  649.  
  650. ls
  651. -----------------------------------------------------------------------
  652.  
  653.  
  654.  
  655. ##############################################
  656. # Log Analysis with Linux command-line tools #
  657. ##############################################
  658. - The following command line executables are found in the Mac as well as most Linux Distributions.
  659.  
  660. cat – prints the content of a file in the terminal window
  661. grep – searches and filters based on patterns
  662. awk – can sort each row into fields and display only what is needed
  663. sed – performs find and replace functions
  664. sort – arranges output in an order
  665. uniq – compares adjacent lines and can report, filter or provide a count of duplicates
  666.  
  667.  
  668.  
  669.  
  670.  
  671. ##############
  672. # Cisco Logs #
  673. ##############
  674. ---------------------------Type This-----------------------------------
  675. cd ~/students/yourname/
  676. mkdir security
  677. cd security
  678. mkdir log_analysis
  679. cd log_analysis
  680. wget http://45.63.104.73/cisco.log
  681. -----------------------------------------------------------------------
  682.  
  683.  
  684. AWK Basics
  685. ----------
  686. - 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.
  687. ---------------------------Type This-----------------------------------
  688. cat cisco.log | awk '{print $5}' | tail -n 4
  689. -----------------------------------------------------------------------
  690.  
  691.  
  692.  
  693. - 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.
  694. ---------------------------Type This-----------------------------------
  695. cat cisco.log | awk '{print $5}'| sort | uniq -c | sort -rn
  696. -----------------------------------------------------------------------
  697.  
  698.  
  699.  
  700. - 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”.
  701. ---------------------------Type This-----------------------------------
  702. cat cisco.log | grep %[a-zA-Z]*-[0-9]-[a-zA-Z]* | awk '{print $5}' | sort | uniq -c | sort -rn
  703. -----------------------------------------------------------------------
  704.  
  705.  
  706.  
  707.  
  708. - 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.
  709. ---------------------------Type This-----------------------------------
  710. cat cisco.log | grep %LINEPROTO-5-UPDOWN:
  711.  
  712. cat cisco.log | grep %LINEPROTO-5-UPDOWN:| awk '{print $10}' | sort | uniq -c | sort -rn
  713.  
  714. cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10}' | sort | uniq -c | sort -rn
  715.  
  716. cat cisco.log | grep %LINEPROTO-5-UPDOWN:| sed 's/,//g' | awk '{print $10 " changed to " $14}' | sort | uniq -c | sort -rn
  717. -----------------------------------------------------------------------
  718.  
  719.  
  720.  
  721.  
  722.  
  723. ##################
  724. # Day 1 Homework #
  725. ##################
  726. Task Option 1: Linux Survival
  727. -----------------------------
  728. Do all of the exercises in Linux Survival (http://linuxsurvival.com/linux-tutorial-introduction/)
  729. Create a word document that contains the screenshots of the quizzes NOTE: You must score a perfect 100 for all 4 quizzes
  730. Name the word document 'YourFirstName-YourLastName-LinuxDay1-LinuxSurvival.docx' (ex: 'Joseph-McCray-LinuxDay1-LinuxSurvival.docx')
  731. Email the document to me at joe-at-secureninja-dot-com before the start of class tomorrow
  732.  
  733.  
  734. Task Option 2: Basic Shell Scripting
  735. ------------------------------------
  736. Watch and do all of the exercises in the video https://www.youtube.com/watch?v=_n5ZegzieSQ
  737. Create a word document that contains the screenshots of the tasks performed in this video
  738. Name the word document 'YourFirstName-YourLastName-LinuxDay1-ShellScripting.docx' (ex: 'Joseph-McCray-LinuxDay1-ShellScripting.docx')
  739. Email the document to me at joe-at-secureninja-dot-com before the start of class tomorrow
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753. ###########################
  754. ############################## # Day 2: Malware Analysis # ##############################
  755. ###########################
  756.  
  757.  
  758.  
  759. ################
  760. # The Scenario #
  761. ################
  762. 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). The fastest thing you can do is perform static analysis.
  763.  
  764.  
  765.  
  766. ####################
  767. # Malware Analysis #
  768. ####################
  769.  
  770.  
  771.  
  772. - After logging please open a terminal window and type the following commands:
  773. ---------------------------Type This-----------------------------------
  774. cd ~/students/yourname/security/
  775. mkdir malware_analysis
  776. cd malware_analysis
  777. -----------------------------------------------------------------------
  778.  
  779. - This is actual Malware (remember to run it in a VM - the password to extract it is 'infected':
  780.  
  781. ---------------------------Type This-----------------------------------
  782. wget https://infosecaddicts-files.s3.amazonaws.com/malware-password-is-infected.zip --no-check-certificate
  783. wget https://infosecaddicts-files.s3.amazonaws.com/analyse_malware.py --no-check-certificate
  784. wget https://infosecaddicts-files.s3.amazonaws.com/wannacry.zip --no-check-certificate
  785.  
  786. unzip malware-password-is-infected.zip
  787. infected
  788.  
  789. file malware.exe
  790.  
  791. mv malware.exe malware.pdf
  792.  
  793. file malware.pdf
  794.  
  795. mv malware.pdf malware.exe
  796.  
  797. hexdump -n 2 -C malware.exe
  798. -----------------------------------------------------------------------
  799.  
  800.  
  801. ***What is '4d 5a' or 'MZ'***
  802. Reference:
  803. http://www.garykessler.net/library/file_sigs.html
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812. ---------------------------Type This-----------------------------------
  813. objdump -x malware.exe
  814.  
  815. strings malware.exe
  816.  
  817. strings --all malware.exe | head -n 6
  818.  
  819. strings malware.exe | grep -i dll
  820.  
  821. strings malware.exe | grep -i library
  822.  
  823. strings malware.exe | grep -i reg
  824.  
  825. strings malware.exe | grep -i hkey
  826.  
  827. strings malware.exe | grep -i hku
  828. -----------------------------------------------------------------------
  829. - We didn't see anything like HKLM, HKCU or other registry type stuff
  830.  
  831.  
  832. ---------------------------Type This-----------------------------------
  833. strings malware.exe | grep -i irc
  834.  
  835. strings malware.exe | grep -i join
  836.  
  837. strings malware.exe | grep -i admin
  838.  
  839. strings malware.exe | grep -i list
  840. -----------------------------------------------------------------------
  841.  
  842. - List of IRC commands: https://en.wikipedia.org/wiki/List_of_Internet_Relay_Chat_commands
  843.  
  844. ---------------------------Type This-----------------------------------
  845. vi analyse_malware.py
  846.  
  847. python analyse_malware.py malware.exe
  848. -----------------------------------------------------------------------
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857. - After logging please open a terminal window and type the following commands:
  858. ---------------------------Type This-----------------------------------
  859. cd ~/students/yourname/security/malware_analysis
  860.  
  861. unzip wannacry.zip
  862. infected
  863.  
  864. file wannacry.exe
  865.  
  866. mv wannacry.exe malware.pdf
  867.  
  868. file malware.pdf
  869.  
  870. mv malware.pdf wannacry.exe
  871.  
  872. hexdump -n 2 -C wannacry.exe
  873. -----------------------------------------------------------------------
  874.  
  875.  
  876.  
  877. ***What is '4d 5a' or 'MZ'***
  878. Reference:
  879. http://www.garykessler.net/library/file_sigs.html
  880.  
  881.  
  882.  
  883.  
  884. ---------------------------Type This-----------------------------------
  885. objdump -x wannacry.exe
  886.  
  887. strings wannacry.exe
  888.  
  889. strings --all wannacry.exe | head -n 6
  890.  
  891. strings wannacry.exe | grep -i dll
  892.  
  893. strings wannacry.exe | grep -i library
  894.  
  895. strings wannacry.exe | grep -i reg
  896.  
  897. strings wannacry.exe | grep -i key
  898.  
  899. strings wannacry.exe | grep -i rsa
  900.  
  901. strings wannacry.exe | grep -i open
  902.  
  903. strings wannacry.exe | grep -i get
  904.  
  905. strings wannacry.exe | grep -i mutex
  906.  
  907. strings wannacry.exe | grep -i irc
  908.  
  909. strings wannacry.exe | grep -i join
  910.  
  911. strings wannacry.exe | grep -i admin
  912.  
  913. strings wannacry.exe | grep -i list
  914. -----------------------------------------------------------------------
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921. Hmmmmm.......what's the latest thing in the news - oh yeah "WannaCry"
  922.  
  923. Quick Google search for "wannacry ransomeware analysis"
  924.  
  925.  
  926. Reference
  927. https://securingtomorrow.mcafee.com/executive-perspectives/analysis-wannacry-ransomware-outbreak/
  928.  
  929. - Yara Rule -
  930.  
  931.  
  932. Strings:
  933. $s1 = “Ooops, your files have been encrypted!” wide ascii nocase
  934. $s2 = “Wanna Decryptor” wide ascii nocase
  935. $s3 = “.wcry” wide ascii nocase
  936. $s4 = “WANNACRY” wide ascii nocase
  937. $s5 = “WANACRY!” wide ascii nocase
  938. $s7 = “icacls . /grant Everyone:F /T /C /Q” wide ascii nocase
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947. Ok, let's look for the individual strings in our file
  948.  
  949.  
  950. ---------------------------Type This-----------------------------------
  951. strings wannacry.exe | grep -i ooops
  952.  
  953. strings wannacry.exe | grep -i wanna
  954.  
  955. strings wannacry.exe | grep -i wcry
  956.  
  957. strings wannacry.exe | grep -i wannacry
  958.  
  959. strings wannacry.exe | grep -i wanacry **** Matches $s5, hmmm.....
  960. -----------------------------------------------------------------------
  961.  
  962.  
  963.  
  964.  
  965.  
  966. ################################
  967. # Good references for WannaCry #
  968. ################################
  969.  
  970. References:
  971.  
  972. https://gist.github.com/rain-1/989428fa5504f378b993ee6efbc0b168
  973. https://securingtomorrow.mcafee.com/executive-perspectives/analysis-wannacry-ransomware-outbreak/
  974. https://joesecurity.org/reports/report-db349b97c37d22f5ea1d1841e3c89eb4.html
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985. ####################################
  986. # Tired of GREP - let's try Python #
  987. ####################################
  988. Decided to make my own script for this kind of stuff in the future. I
  989.  
  990. Reference1:
  991. https://infosecaddicts-files.s3.amazonaws.com/analyse_malware.py
  992.  
  993. This is a really good script for the basics of static analysis
  994.  
  995. Reference:
  996. https://joesecurity.org/reports/report-db349b97c37d22f5ea1d1841e3c89eb4.html
  997.  
  998.  
  999. This is really good for showing some good signatures to add to the Python script
  1000.  
  1001.  
  1002. Here is my own script using the signatures (started this yesterday, but still needs work):
  1003. https://pastebin.com/guxzCBmP
  1004.  
  1005.  
  1006.  
  1007. ---------------------------Type This-----------------------------------
  1008. wget https://pastebin.com/raw/guxzCBmP
  1009.  
  1010.  
  1011. mv guxzCBmP am.py
  1012.  
  1013.  
  1014. vi am.py
  1015.  
  1016. python am.py wannacry.exe
  1017. -----------------------------------------------------------------------
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025. ##############
  1026. # Yara Ninja #
  1027. ##############
  1028. Hmmmmm.......what's the latest thing in the news - oh yeah "WannaCry"
  1029.  
  1030. Quick Google search for "wannacry ransomeware analysis"
  1031.  
  1032.  
  1033. Reference
  1034. https://www.mcafee.com/blogs/other-blogs/executive-perspectives/analysis-wannacry-ransomware-outbreak/
  1035.  
  1036.  
  1037.  
  1038. - Yara Rule -
  1039.  
  1040.  
  1041. Strings:
  1042. $s1 = “Ooops, your files have been encrypted!” wide ascii nocase
  1043. $s2 = “Wanna Decryptor” wide ascii nocase
  1044. $s3 = “.wcry” wide ascii nocase
  1045. $s4 = “WANNACRY” wide ascii nocase
  1046. $s5 = “WANACRY!” wide ascii nocase
  1047. $s7 = “icacls . /grant Everyone:F /T /C /Q” wide ascii nocase
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056. Ok, let's look for the individual strings
  1057.  
  1058. ---------------------------Type This-----------------------------------
  1059.  
  1060.  
  1061. strings wannacry.exe | grep -i ooops
  1062.  
  1063. strings wannacry.exe | grep -i wanna
  1064.  
  1065. strings wannacry.exe | grep -i wcry
  1066.  
  1067. strings wannacry.exe | grep -i wannacry
  1068.  
  1069. strings wannacry.exe | grep -i wanacry **** Matches $s5, hmmm.....
  1070.  
  1071.  
  1072. -----------------------------------------------------------------------
  1073.  
  1074.  
  1075.  
  1076.  
  1077. Let's see if we can get yara working.
  1078. ---------------------------Type This-----------------------------------
  1079. cd ~/students/yourname/security/malware_analysis
  1080.  
  1081. mkdir quick_yara
  1082.  
  1083. cd quick_yara
  1084. wget http://45.63.104.73/wannacry.zip
  1085.  
  1086. unzip wannacry.zip
  1087. **** password is infected ***
  1088. -----------------------------------------------------------------------
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094. ---------------------------Type This-----------------------------------
  1095.  
  1096. nano wannacry_1.yar
  1097.  
  1098. ---------------------------Paste This-----------------------------------
  1099. rule wannacry_1 : ransom
  1100. {
  1101. meta:
  1102. author = "Joshua Cannell"
  1103. description = "WannaCry Ransomware strings"
  1104. weight = 100
  1105. date = "2017-05-12"
  1106.  
  1107. strings:
  1108. $s1 = "Ooops, your files have been encrypted!" wide ascii nocase
  1109. $s2 = "Wanna Decryptor" wide ascii nocase
  1110. $s3 = ".wcry" wide ascii nocase
  1111. $s4 = "WANNACRY" wide ascii nocase
  1112. $s5 = "WANACRY!" wide ascii nocase
  1113. $s7 = "icacls . /grant Everyone:F /T /C /Q" wide ascii nocase
  1114.  
  1115. condition:
  1116. any of them
  1117. }
  1118.  
  1119. ----------------------------------------------------------------------------
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125. ---------------------------Type This-----------------------------------
  1126.  
  1127. yara wannacry_1.yar wannacry.exe
  1128.  
  1129. -----------------------------------------------------------------------
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135. ---------------------------Type This-----------------------------------
  1136.  
  1137. nano wannacry_2.yar
  1138.  
  1139. ---------------------------Paste This-----------------------------------
  1140. rule wannacry_2{
  1141. meta:
  1142. author = "Harold Ogden"
  1143. description = "WannaCry Ransomware Strings"
  1144. date = "2017-05-12"
  1145. weight = 100
  1146.  
  1147. strings:
  1148. $string1 = "msg/m_bulgarian.wnry"
  1149. $string2 = "msg/m_chinese (simplified).wnry"
  1150. $string3 = "msg/m_chinese (traditional).wnry"
  1151. $string4 = "msg/m_croatian.wnry"
  1152. $string5 = "msg/m_czech.wnry"
  1153. $string6 = "msg/m_danish.wnry"
  1154. $string7 = "msg/m_dutch.wnry"
  1155. $string8 = "msg/m_english.wnry"
  1156. $string9 = "msg/m_filipino.wnry"
  1157. $string10 = "msg/m_finnish.wnry"
  1158. $string11 = "msg/m_french.wnry"
  1159. $string12 = "msg/m_german.wnry"
  1160. $string13 = "msg/m_greek.wnry"
  1161. $string14 = "msg/m_indonesian.wnry"
  1162. $string15 = "msg/m_italian.wnry"
  1163. $string16 = "msg/m_japanese.wnry"
  1164. $string17 = "msg/m_korean.wnry"
  1165. $string18 = "msg/m_latvian.wnry"
  1166. $string19 = "msg/m_norwegian.wnry"
  1167. $string20 = "msg/m_polish.wnry"
  1168. $string21 = "msg/m_portuguese.wnry"
  1169. $string22 = "msg/m_romanian.wnry"
  1170. $string23 = "msg/m_russian.wnry"
  1171. $string24 = "msg/m_slovak.wnry"
  1172. $string25 = "msg/m_spanish.wnry"
  1173. $string26 = "msg/m_swedish.wnry"
  1174. $string27 = "msg/m_turkish.wnry"
  1175. $string28 = "msg/m_vietnamese.wnry"
  1176.  
  1177.  
  1178. condition:
  1179. any of ($string*)
  1180. }
  1181. ----------------------------------------------------------------------------
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190. ---------------------------Type This-----------------------------------
  1191.  
  1192. yara wannacry_2.yar wannacry.exe
  1193.  
  1194. -----------------------------------------------------------------------
  1195.  
  1196.  
  1197.  
  1198. ---------------------------Type This-----------------------------------
  1199. cd ~/students/yourname/security/malware_analysis/quick_yara
  1200.  
  1201. git clone https://github.com/Yara-Rules/rules.git
  1202.  
  1203. cd rules/
  1204.  
  1205. ./index_gen.sh
  1206.  
  1207. ls
  1208.  
  1209. cd malware/
  1210.  
  1211. ls | grep -i ransom
  1212.  
  1213. ls | grep -i rat
  1214.  
  1215. ls | grep -i toolkit
  1216.  
  1217. ls | grep -i apt
  1218.  
  1219. cd ..
  1220.  
  1221. cd capabilities/
  1222.  
  1223. ls
  1224.  
  1225. cat capabilities.yar
  1226.  
  1227. cd ..
  1228.  
  1229. cd cve_rules/
  1230.  
  1231. ls
  1232.  
  1233. cd ..
  1234.  
  1235. ./index_gen.sh
  1236.  
  1237. cd ..
  1238.  
  1239. yara -w rules/index.yar wannacry.exe
  1240.  
  1241.  
  1242. ----------------------------------------------------------------------
  1243.  
  1244.  
  1245. References:
  1246. https://www.slideshare.net/JohnLaycock1/yet-another-yara-allocution-yaya
  1247. https://www.slideshare.net/KasperskyLabGlobal/upping-the-apt-hunting-game-learn-the-best-yara-practices-from-kaspersky
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255. #####################################################
  1256. # Analyzing Macro Embedded Malware #
  1257. #####################################################
  1258. ---------------------------Type This-----------------------------------
  1259. cd ~/students/yourname/security/malware_analysis
  1260.  
  1261. mkdir macro_docs
  1262.  
  1263. cd macro_docs
  1264.  
  1265. wget https://infosecaddicts-files.s3.amazonaws.com/064016.zip
  1266.  
  1267. wget http://didierstevens.com/files/software/oledump_V0_0_22.zip
  1268.  
  1269. unzip oledump_V0_0_22.zip
  1270.  
  1271. unzip 064016.zip
  1272. infected
  1273.  
  1274. python oledump.py 064016.doc
  1275.  
  1276. python oledump.py 064016.doc -s A4 -v
  1277. -----------------------------------------------------------------------
  1278.  
  1279.  
  1280.  
  1281. - From this we can see this Word doc contains an embedded file called editdata.mso which contains seven data streams.
  1282. - Three of the data streams are flagged as macros: A3:’VBA/Module1′, A4:’VBA/Module2′, A5:’VBA/ThisDocument’.
  1283.  
  1284. ---------------------------Type This-----------------------------------
  1285. python oledump.py 064016.doc -s A5 -v
  1286. -----------------------------------------------------------------------
  1287.  
  1288. - As far as I can tell, VBA/Module2 does absolutely nothing. These are nonsensical functions designed to confuse heuristic scanners.
  1289.  
  1290. ---------------------------Type This-----------------------------------
  1291. python oledump.py 064016.doc -s A3 -v
  1292.  
  1293. - Look for "GVhkjbjv" and you should see:
  1294.  
  1295. 636D64202F4B20706F7765727368656C6C2E657865202D457865637574696F6E506F6C69637920627970617373202D6E6F70726F66696C6520284E65772D4F626A6563742053797374656D2E4E65742E576562436C69656E74292E446F776E6C6F616446696C652827687474703A2F2F36322E37362E34312E31352F6173616C742F617373612E657865272C272554454D50255C4A494F696F646668696F49482E63616227293B20657870616E64202554454D50255C4A494F696F646668696F49482E636162202554454D50255C4A494F696F646668696F49482E6578653B207374617274202554454D50255C4A494F696F646668696F49482E6578653B
  1296.  
  1297. - Take that long blob that starts with 636D and finishes with 653B and paste it in:
  1298. http://www.rapidtables.com/convert/number/hex-to-ascii.htm
  1299. -----------------------------------------------------------------------
  1300.  
  1301.  
  1302.  
  1303.  
  1304. #########################################
  1305. # Security Operations Center Job Roles #
  1306. # Intrusion Analysis Level 1 #
  1307. #########################################
  1308. Required Technical Skills: Comfortable with basic Linux/Windows (MCSA/Linux+)
  1309. Comfortable with basic network (Network+)
  1310. Comfortable with security fundamentals (Security+)
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316. Job Task: Process security events, follow incident response triage playbook
  1317.  
  1318. #########################################
  1319. # Security Operations Center Job Roles #
  1320. # Intrusion Analysis Level 2 #
  1321. #########################################
  1322.  
  1323. Required Technical Skills: Comfortable with basic Linux/Windows system administration
  1324. Comfortable with basic network administration
  1325. Comfortable with basic programming
  1326. Comfortable researching IT security issues
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332. Job Task: Perform detailed malware analysis, assist with development of the incident response triage playbook
  1333.  
  1334. Sample Playbook: https://infosecaddicts-files.s3.amazonaws.com/IR-Program-and-Playbooks.zip
  1335.  
  1336.  
  1337.  
  1338. #########################################
  1339. # Security Operations Center Job Roles #
  1340. # Intrusion Analysis Level 3 #
  1341. #########################################
  1342.  
  1343. Required Technical Skills: Strong statistical analysis background
  1344. Strong programming background (C, C++, Java, Assembly, scripting languages)
  1345. Advanced system/network administration background
  1346. Comfortable researching IT security issues
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352. Job Task: Perform detailed malware analysis
  1353. Perform detailed statistical analysis
  1354. Assist with development of the incident response triage playbook
  1355.  
  1356.  
  1357.  
  1358.  
  1359. #################################################
  1360. # Good references for learning Malware Analysis #
  1361. #################################################
  1362.  
  1363. References:
  1364. https://www.slideshare.net/SamBowne/cnit-126-ch-0-malware-analysis-primer-1-basic-static-techniques
  1365. https://www.slideshare.net/grecsl/malware-analysis-101-n00b-to-ninja-in-60-minutes-at-bsideslv-on-august-5-2014
  1366. https://www.slideshare.net/Bletchley131/intro-to-static-analysis
  1367.  
  1368.  
  1369.  
  1370. ##################
  1371. # Day 2 Homework #
  1372. ##################
  1373.  
  1374. Task Option 1: Basic Shell Scripting
  1375. ------------------------------------
  1376. Watch and do all of the exercises in the video https://www.youtube.com/watch?v=GtovwKDemnI
  1377. Create a word document that contains the screenshots of the tasks performed in this video
  1378. Name the word document 'YourFirstName-YourLastName-LinuxDay2-ShellScripting.docx' (ex: 'Joseph-McCray-LinuxDay2-ShellScripting.docx')
  1379. Email the document to me at joe-at-secureninja-dot-com before the start of class tomorrow
  1380.  
  1381.  
  1382. Task Option 2: Advanced Shell Scripting
  1383. ---------------------------------------
  1384. Watch and do all of the exercises in the video https://www.youtube.com/watch?v=aNQCl_ByM20&t=4045s
  1385. Create a word document that contains the screenshots of the tasks performed in this video
  1386. Name the word document 'YourFirstName-YourLastName-LinuxDay2-AdvancedShellScripting.docx' (ex: 'Joseph-McCray-LinuxDay2-AdvancedShellScripting.docx')
  1387. Email the document to me at joe-at-secureninja-dot-com before the start of class tomorrow
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.  
  1400.  
  1401. #####################################
  1402. ############################## # Day 3: Threat Hunting on the wire # ##############################
  1403. #####################################
  1404.  
  1405.  
  1406.  
  1407.  
  1408. - After logging please open a terminal window and type the following commands:
  1409. ---------------------------Type This-----------------------------------
  1410. cd ~/students/yourname/security/
  1411. mkdir pcap_analysis
  1412. cd pcap_analysis
  1413. -----------------------------------------------------------------------
  1414.  
  1415.  
  1416.  
  1417.  
  1418. ##################################################################
  1419. # Analyzing a PCAP Prads #
  1420. # Note: run as regular user #
  1421. ##################################################################
  1422.  
  1423. ---------------------------Type this as a regular user----------------------------------
  1424. cd ~/students/yourname/security/pcap_analysis/
  1425.  
  1426. mkdir prads
  1427.  
  1428. cd prads
  1429.  
  1430. wget http://45.63.104.73/suspicious-time.pcap
  1431.  
  1432. prads -r suspicious-time.pcap -l prads-asset.log
  1433.  
  1434. cat prads-asset.log | less
  1435.  
  1436. cat prads-asset.log | grep SYN | grep -iE 'windows|linux'
  1437.  
  1438. cat prads-asset.log | grep CLIENT | grep -iE 'safari|firefox|opera|chrome'
  1439.  
  1440. cat prads-asset.log | grep SERVER | grep -iE 'apache|linux|ubuntu|nginx|iis'
  1441. -----------------------------------------------------------------------
  1442.  
  1443.  
  1444.  
  1445.  
  1446. ##################################
  1447. # PCAP Analysis with ChaosReader #
  1448. # Note: run as regular user #
  1449. ##################################
  1450. ---------------------------Type this as a regular user----------------------------------
  1451. cd ~/students/yourname/security/pcap_analysis/
  1452.  
  1453. mkdir chaos_reader/
  1454.  
  1455. cd chaos_reader/
  1456.  
  1457. wget http://45.63.104.73/suspicious-time.pcap
  1458.  
  1459. wget http://45.63.104.73/chaosreader.pl
  1460.  
  1461. perl chaosreader.pl suspicious-time.pcap
  1462.  
  1463. cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)"
  1464.  
  1465. cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)" | awk '{print $4, $5, $6}' | sort | uniq -c | sort -nr
  1466.  
  1467.  
  1468. 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
  1469.  
  1470.  
  1471.  
  1472. 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 | awk '{print $5}' > url.lst
  1473.  
  1474.  
  1475. wget https://raw.githubusercontent.com/Open-Sec/forensics-scripts/master/check-urls-virustotal.py
  1476.  
  1477.  
  1478. python check-urls-virustotal.py url.lst
  1479.  
  1480.  
  1481.  
  1482. ------------------------------------------------------------------------
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491. #############################
  1492. # PCAP Analysis with tshark #
  1493. # Note: run as regular user #
  1494. #############################
  1495. ---------------------------Type this as a regular user---------------------------------
  1496. cd ~/students/yourname/security/pcap_analysis/
  1497.  
  1498. mkdir tshark
  1499.  
  1500. cd tshark/
  1501.  
  1502. wget http://45.63.104.73/suspicious-time.pcap
  1503.  
  1504. tshark -i ens3 -r suspicious-time.pcap -qz io,phs
  1505.  
  1506. tshark -r suspicious-time.pcap -qz ip_hosts,tree
  1507.  
  1508. tshark -r suspicious-time.pcap -Y "http.request" -Tfields -e "ip.src" -e "http.user_agent" | uniq
  1509.  
  1510. tshark -r suspicious-time.pcap -Y "dns" -T fields -e "ip.src" -e "dns.flags.response" -e "dns.qry.name"
  1511.  
  1512.  
  1513. 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}'
  1514.  
  1515. whois rapidshare.com.eyu32.ru
  1516.  
  1517. whois sploitme.com.cn
  1518.  
  1519. 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'
  1520.  
  1521. tshark -r suspicious-time.pcap -qz http_req,tree
  1522.  
  1523. tshark -r suspicious-time.pcap -Y "data-text-lines contains \"<script\"" -T fields -e frame.number -e ip.src -e ip.dst
  1524.  
  1525. 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'
  1526. ------------------------------------------------------------------------
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532. ###############################
  1533. # Extracting files from PCAPs #
  1534. # Note: run as regular user #
  1535. ###############################
  1536. ---------------------------Type this as a regular user---------------------------------
  1537. cd ~/students/yourname/security/pcap_analysis/
  1538.  
  1539. mkdir extract_files
  1540.  
  1541. cd extract_files
  1542.  
  1543. wget http://45.63.104.73/suspicious-time.pcap
  1544.  
  1545. foremost -v -i suspicious-time.pcap
  1546.  
  1547. cd output
  1548.  
  1549. ls
  1550.  
  1551. cat audit.txt
  1552.  
  1553. cd exe
  1554.  
  1555. wget https://raw.githubusercontent.com/GREEKYnikhilsharma/Xen0ph0n-VirusTotal_API_Tool-Python3/master/vtlite.py
  1556. ---------------------------------------------------------------------------------------
  1557.  
  1558.  
  1559. ******* NOTE: You will need to put your virustotal API key in vtlite.py *******
  1560. * Create an account in virustotal > login > click on your profile > API key > copy API key > in terminal do nano vtlite.py >
  1561. * Paste the API key in where it says > profit
  1562. ********************************************************************************
  1563.  
  1564. ---------------------------Type this as a regular user---------------------------------
  1565. for f in *.exe; do python3 vtlite.py -s $f; sleep 20; done
  1566. ---------------------------------------------------------------------------------------
  1567.  
  1568.  
  1569. ###############################
  1570. # PCAP Analysis with Suricata #
  1571. # Note: run as root #
  1572. ###############################
  1573. --------------------------Type this as root--------------------------------
  1574. cd ~/students/yourname/security/pcap_analysis/
  1575.  
  1576. mkdir suricata
  1577.  
  1578. cd suricata/
  1579.  
  1580. wget http://45.63.104.73/suspicious-time.pcap
  1581.  
  1582. mkdir suri
  1583.  
  1584. sudo suricata -c /etc/suricata/suricata.yaml -r suspicious-time.pcap -l suri/
  1585.  
  1586. cd suri/
  1587.  
  1588. cat stats.log | less
  1589.  
  1590. cat eve.json |grep -E "e\":\"http"|jq ".timestamp,.http"|csplit - /..T..:/ {*}
  1591.  
  1592. cat xx01
  1593.  
  1594. cat xx02
  1595.  
  1596. cat xx03
  1597.  
  1598. cat xx04
  1599.  
  1600. cat xx05
  1601.  
  1602. cat xx06
  1603. ------------------------------------------------------------------------
  1604.  
  1605.  
  1606. #############################
  1607. # PCAP Analysis with Yara #
  1608. # Note: run as regular user #
  1609. #############################
  1610. -------------------------Type this as a regular user----------------------------------
  1611. cd ~/students/yourname/security/pcap_analysis/
  1612.  
  1613. git clone https://github.com/kevthehermit/YaraPcap.git
  1614. cd YaraPcap/
  1615. wget http://45.63.104.73/suspicious-time.pcap
  1616. wget https://github.com/Yara-Rules/rules/archive/master.zip
  1617. unzip master.zip
  1618. cd rules-master/
  1619. ls
  1620. cat index.yar
  1621. clear
  1622. ./index_gen.sh
  1623. cd ..
  1624. mkdir matching_files/
  1625. python yaraPcap.py rules-master/index.yar suspicious-time.pcap -s matching_files/
  1626. whereis tcpflow
  1627. vi yaraPcap.py **** fix line 35 with correct path to tcpflow (/usr/bin/tcpflow)****
  1628. python yaraPcap.py rules-master/index.yar suspicious-time.pcap -s matching_files/
  1629. cd matching_files/
  1630. ls
  1631. cat report.txt
  1632. ------------------------------------------------------------------------
  1633.  
  1634.  
  1635.  
  1636.  
  1637. #################################################################################
  1638. # Now that you know packet analysis here are the next set of files to play with #
  1639. #################################################################################
  1640. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/APT41/APT41_StoreSyncSvc.pcap
  1641. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/Agent_Tesla/agenttesla_09July2019.pcap
  1642. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/CVE-2019-9978/CVE-2019-9978_attempt_05May2019.pcap
  1643. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/Powershell/Powershell_script_19Dec2019.pcap
  1644. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/sharik_smoke/sharik_smoke.pcap
  1645. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/Microsoft/CVE-2019-0703.pcap
  1646. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/Microsoft/CVE-2019-0801.pcap
  1647.  
  1648.  
  1649.  
  1650. References:
  1651. https://www.slideshare.net/j0b1n/tcpdump-hunter
  1652. https://www.slideshare.net/AviNetworks/reconsider-tcpdump-for-modern-troubleshooting
  1653.  
  1654.  
  1655. ##################
  1656. # Day 3 Homework #
  1657. ##################
  1658.  
  1659. Task Option 1: Shell Scripting
  1660. ------------------------------------
  1661. Watch and do all of the exercises in the video https://www.youtube.com/watch?v=hwrnmQumtPw
  1662. Create a word document that contains the screenshots of the tasks performed in this video
  1663. Name the word document 'YourFirstName-YourLastName-LinuxDay3-ShellScripting.docx' (ex: 'Joseph-McCray-LinuxDay3-ShellScripting.docx')
  1664. Email the document to me at joe-at-secureninja-dot-com before the start of class tomorrow
  1665.  
  1666.  
  1667. Task Option 2: Python3
  1668. ---------------------------------------
  1669. Watch and do all of the exercises in the first 7 videos from https://www.youtube.com/playlist?list=PLypxmOPCOkHVzhKRcWzEkQXCnmHezGVeB
  1670. Create a word document that contains the screenshots of the tasks performed in these videos
  1671. Name the word document 'YourFirstName-YourLastName-LinuxDay3-AdvancedShellScripting.docx' (ex: 'Joseph-McCray-LinuxDay3-AdvancedShellScripting.docx')
  1672. Email the document to me at joe-at-secureninja-dot-com before the start of class tomorrow
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685. ################################################################
  1686. ############################## # Day 4: Programming Fundamentals & Offensive Cyber Operations # ##############################
  1687. ################################################################
  1688.  
  1689. ------------------------------- Programming fundamentals -------------------------------
  1690.  
  1691.  
  1692. Joe rule #1 single quote, single quote, left arrow
  1693. --------------------------------------------------
  1694. '' <-- as soon as you type '', then hit your left arrow key to put you inside of the ''
  1695. "" <-- as soon as you type "", then hit your left arrow key to put you inside of the ""
  1696. something() <-- as soon as you type (), then hit your left arrow key to put you inside of the ()
  1697. something[] <-- as soon as you type [], then hit your left arrow key to put you inside of the []
  1698. something{} <-- as soon as you type {}, then hit your left arrow key to put you inside of the {}
  1699.  
  1700. -- Now kick it up a notch
  1701. [] <-- as soon as you type [], then hit your left arrow key to put you inside of the []
  1702. [()] <-- as soon as you type (), then hit your left arrow key to put you inside of the ()
  1703. [({})] <-- as soon as you type {}, then hit your left arrow key to put you inside of the {}
  1704. [({"''"})] <-- as soon as you type "", then hit your left arrow key to put you inside of the ""
  1705. [({"''"})] <-- as soon as you type '', then hit your left arrow key to put you inside of the ''
  1706.  
  1707.  
  1708.  
  1709. Joe rule #2 "Code can only do 3 things"
  1710. --------------------------------------
  1711.  
  1712. Process - read, write, math
  1713.  
  1714. Decision - if/then
  1715.  
  1716. Loop - for
  1717.  
  1718.  
  1719.  
  1720.  
  1721. Joe rule #3 "Never more than 5-10"
  1722. ---------------------------------
  1723.  
  1724. -----5 lines of code----
  1725. line 1 blah blah blah
  1726. line 2 blah blah blah
  1727. line 3 blah blah blah
  1728. line 4 blah blah blah
  1729. line 5 blah blah blah
  1730.  
  1731.  
  1732. sales_tax = price * tax_rate
  1733.  
  1734.  
  1735. 0.80 = 10 * 0.08
  1736.  
  1737. -----5-10 lines of code---- = function
  1738. price = 10
  1739.  
  1740. def st():
  1741. sales_tax = price * 0.08
  1742. print(sales_tax)
  1743.  
  1744.  
  1745. st(10) <---- how to run a function
  1746.  
  1747. -----5-10 functions ---- = class "tax class"
  1748. st()
  1749. lt()
  1750. pt()
  1751. it()
  1752. dt()
  1753.  
  1754.  
  1755.  
  1756. tax.st()
  1757. tax.lt()
  1758.  
  1759. -----5-10 functions ---- = class "expense class"
  1760. gas()
  1761. elec()
  1762. water()
  1763. food()
  1764. beer()
  1765.  
  1766. expense.gas()
  1767.  
  1768.  
  1769. -----5-10 classes ---- = module "finance module"
  1770.  
  1771. import finance
  1772.  
  1773.  
  1774. ------------------------------- Summary of fundamentals ------------------------------
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.  
  1787.  
  1788.  
  1789.  
  1790. Let's look at a simple for loop
  1791. ---------------------------Type This-----------------------------------
  1792. cd ~/students/yourname/
  1793. mkdir programming_fundamentals
  1794. cd programming_fundamentals
  1795. cp ~/wannacry.exe .
  1796. nano forloop_malware_analysis.sh
  1797.  
  1798. ---------------------------Paste This-----------------------------------
  1799. #!/bin/bash
  1800.  
  1801. ransomeware=('CryptImportKey' 'CryptDecrypt' 'CryptDestroyKey' 'CryptReleaseContext' 'EntryPo int' 'CryptAcquireContextA' 'lstrcpyW' 'lstrlenW' 'lstrcatW' 'CloseHandle' 'lstrcmpiA' 'RegOp enKeyExA' 'lstrlenA' 'RegSetValueExA' 'RegCloseKey' 'RegQueryValueExA' 'GetLastError' 'GetEnv ironmentVariableA' 'ShellExecuteA' 'Sleep' 'CryptGenKey' 'CryptExportKey' 'CryptEncrypt' 'KiU serExceptionDispatcher' 'RtlZeroMemory' 'MultiByteToWideChar' 'lstrcatA' 'RegCreateKeyA' 'SHC hangeNotify' 'SetErrorMode' 'CryptGenKey' 'CryptImportKey');
  1802.  
  1803. # This is just a test to read all of the values in the array
  1804.  
  1805. #echo ${ransomeware[@]}
  1806.  
  1807. # This is a quick for loop to run strings and grep for everything in the array
  1808. # Reference: http://www.masteringunixshell.net/qa3/bash-how-to-echo-array.html
  1809.  
  1810. for ELEMENT in ${ransomeware[@]}
  1811. do
  1812. #echo string: $ELEMENT
  1813. strings wannacry.exe | grep -i $ELEMENT
  1814. done
  1815. --------------------------------------------------
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824. Ok, now let's run it
  1825. ---------------------------Type This-----------------------------------
  1826. chmod +x forloop_malware_analysis.sh
  1827. ./forloop_malware_analysis.sh
  1828. ------------------------------------------------------------------------
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835. Let's look at a simple menu
  1836. ---------------------------Type This-----------------------------------
  1837.  
  1838. nano simple_menu.sh
  1839.  
  1840. ---------------------------Paste This-----------------------------------
  1841. #!/bin/bash
  1842. # simple menu to do various functions
  1843. # Reference: http://www.seafriends.org.nz/linux/menus.htm
  1844.  
  1845.  
  1846. while [ answer != "0" ]
  1847. do
  1848. clear
  1849. echo "Select from the following functions"
  1850. echo " 0 exit"
  1851. echo " 1 Network Asset Inventory"
  1852. echo " 2 IP to IP communication and URL lookup"
  1853. echo " 3 Extract files"
  1854. echo " 4 exit"
  1855.  
  1856.  
  1857. read -p " ?" answer
  1858. case $answer in
  1859. 0) break ;;
  1860. 1) echo "Network Asset Inventory"
  1861. prads -r suspicious-time.pcap -l prads-asset.log
  1862. cat prads-asset.log | grep SYN | grep -iE 'windows|linux'
  1863. cat prads-asset.log | grep CLIENT | grep -iE 'safari|firefox|opera|chrome'
  1864. cat prads-asset.log | grep SERVER | grep -iE 'apache|linux|ubuntu|nginx|iis'
  1865. ;;
  1866. 2) echo "IP to IP communication and URL lookup"
  1867. 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'
  1868. ;;
  1869. 3) echo "Extract files"
  1870. foremost -v -i suspicious-time.pcap
  1871. cat output/audit.txt
  1872. ;;
  1873. 4) break ;;
  1874. *) break ;;
  1875. esac
  1876. echo "press RETURN for menu"
  1877. read key
  1878. done
  1879. exit 0
  1880. --------------------------------------------------
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889. Ok, now let's run it
  1890. ---------------------------Type This-----------------------------------
  1891. chmod +x simple_menu.sh
  1892. ./simple_menu.sh
  1893. ------------------------------------------------------------------------
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900. Let's look at a simple function
  1901. ---------------------------Type This-----------------------------------
  1902.  
  1903. nano hello_world.sh
  1904.  
  1905. ---------------------------Paste This-----------------------------------
  1906. #!/bin/bash
  1907. # Reference: https://linuxize.com/post/bash-functions/
  1908.  
  1909. hello_world () {
  1910. echo 'hello, world'
  1911. }
  1912.  
  1913. hello_world
  1914. --------------------------------------------------
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921. Ok, now let's run it
  1922. ---------------------------Type This-----------------------------------
  1923. chmod +x hello_world.sh
  1924. ./hello_world.sh
  1925. ------------------------------------------------------------------------
  1926.  
  1927.  
  1928.  
  1929.  
  1930. Let's ask the user a question
  1931. ---------------------------Type This-----------------------------------
  1932.  
  1933. nano prompt_for_user_input.sh
  1934.  
  1935. ---------------------------Paste This-----------------------------------
  1936. #!/bin/bash
  1937. # Reference: https://tecadmin.net/prompt-user-input-in-linux-shell-script/
  1938.  
  1939. read -p "Enter Your Name: " username
  1940. echo "Welcome $username!"
  1941. ------------------------------------------------------------------------
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948. Ok, now let's run it
  1949. ---------------------------Type This-----------------------------------
  1950. chmod +x prompt_for_user_input.sh
  1951. ./prompt_for_user_input.sh
  1952. ------------------------------------------------------------------------
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959. Let's make the function do something useful
  1960. ---------------------------Type This-----------------------------------
  1961.  
  1962. nano ip_2_url_lookup.sh
  1963.  
  1964. ---------------------------Paste This-----------------------------------
  1965. #!/bin/bash
  1966. # Reference: https://linuxize.com/post/bash-functions/
  1967.  
  1968. do_stuff () {
  1969. 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'
  1970. }
  1971.  
  1972. do_stuff
  1973. ------------------------------------------------------------------------
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980. Ok, now let's run it
  1981. ---------------------------Type This-----------------------------------
  1982. chmod +x ip_2_url_lookup.sh
  1983. ./ip_2_url_lookup.sh
  1984. ------------------------------------------------------------------------
  1985.  
  1986.  
  1987.  
  1988.  
  1989. Let's grab some PCAP files
  1990. ---------------------------Type This-----------------------------------
  1991. cd ~/students/yourname/programming_fundamentals
  1992. mkdir pcaps
  1993. cd pcaps
  1994. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/APT41/APT41_StoreSyncSvc.pcap
  1995. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/Agent_Tesla/agenttesla_09July2019.pcap
  1996. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/CVE-2019-9978/CVE-2019-9978_attempt_05May2019.pcap
  1997. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/Powershell/Powershell_script_19Dec2019.pcap
  1998. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/sharik_smoke/sharik_smoke.pcap
  1999. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/Microsoft/CVE-2019-0703.pcap
  2000. wget https://github.com/SpiderLabs/IOCs-IDPS/raw/master/Microsoft/CVE-2019-0801.pcap
  2001. ------------------------------------------------------------------------
  2002.  
  2003.  
  2004. Let's read file names into an array
  2005. ---------------------------Type This-----------------------------------
  2006.  
  2007. nano parse_pcap_file_names.sh
  2008.  
  2009. ---------------------------Paste This-----------------------------------
  2010. #!/bin/bash
  2011. # Reference: https://delightlylinux.wordpress.com/2017/04/08/put-filenames-in-bash-array/
  2012.  
  2013. #!/bin/bash
  2014.  
  2015. declare -a arrPCAPs
  2016. for file in *.pcap
  2017. do
  2018. arrPCAPs=("${PCAPs[@]}" "$file")
  2019. echo ${arrPCAPs[@]}
  2020. done
  2021. ------------------------------------------------------------------------
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028. Ok, now let's run it
  2029. ---------------------------Type This-----------------------------------
  2030. chmod +x parse_pcap_file_names.sh
  2031. ./parse_pcap_file_names.sh
  2032. ------------------------------------------------------------------------
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048. ##################
  2049. # Day 4 Homework #
  2050. ##################
  2051.  
  2052. Task Option 1: Shell Scripting
  2053. ------------------------------------
  2054. Watch and do all of the exercises in the video https://www.youtube.com/watch?v=hwrnmQumtPw
  2055. Create a word document that contains the screenshots of the tasks performed in this video
  2056. Name the word document 'YourFirstName-YourLastName-LinuxDay4-ShellScripting.docx' (ex: 'Joseph-McCray-LinuxDay3-ShellScripting.docx')
  2057. Email the document to me at joe-at-secureninja-dot-com before the start of class tomorrow
  2058.  
  2059.  
  2060. Task Option 2: Python3
  2061. ---------------------------------------
  2062. Watch and do all of the exercises in the first 7 videos from https://www.youtube.com/playlist?list=PLypxmOPCOkHVzhKRcWzEkQXCnmHezGVeB
  2063. Create a word document that contains the screenshots of the tasks performed in these videos
  2064. Name the word document 'YourFirstName-YourLastName-LinuxDay4-Python3.docx' (ex: 'Joseph-McCray-LinuxDay3-Python3.docx.docx')
  2065. Email the document to me at joe-at-secureninja-dot-com before the start of class tomorrow
  2066.  
  2067.  
  2068.  
  2069.  
  2070. ####################
  2071. ############################## # Day 5: Challenge # ##############################
  2072. ####################
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115. ###################
  2116. # Memory Analysis #
  2117. ###################
  2118. ---------------------------Type This-----------------------------------
  2119. cd ~/Desktop/
  2120.  
  2121. sudo apt-get install -y foremost tcpxtract
  2122.  
  2123. wget https://infosecaddicts-files.s3.amazonaws.com/hn_forensics.vmem
  2124.  
  2125. git clone https://github.com/volatilityfoundation/volatility.git
  2126.  
  2127. cd volatility
  2128. sudo pip install distorm3
  2129. sudo python setup.py install
  2130. python vol.py -h
  2131. python vol.py pslist -f ~/Desktop/hn_forensics.vmem
  2132. python vol.py connscan -f ~/Desktop/hn_forensics.vmem
  2133. mkdir dump/
  2134. mkdir -p output/pdf/
  2135. python vol.py -f ~/Desktop/hn_forensics.vmem memdmp -p 888 -D dump/
  2136. python vol.py -f ~/Desktop/hn_forensics.vmem memdmp -p 1752 -D dump/
  2137. ***Takes a few min***
  2138. strings 1752.dmp | grep "^http://" | sort | uniq
  2139. strings 1752.dmp | grep "Ahttps://" | uniq -u
  2140. cd ..
  2141. foremost -i ~/Desktop/volatility/dump/1752.dmp -t pdf -o output/pdf/
  2142. cd ~/Desktop/volatility/output/pdf/
  2143. cat audit.txt
  2144. cd pdf
  2145. ls
  2146. grep -i javascript *.pdf
  2147.  
  2148.  
  2149.  
  2150. cd ~/Desktop/volatility/output/pdf/
  2151. wget http://didierstevens.com/files/software/pdf-parser_V0_6_4.zip
  2152. unzip pdf-parser_V0_6_4.zip
  2153. python pdf-parser.py -s javascript --raw pdf/00601560.pdf
  2154. python pdf-parser.py --object 11 00600328.pdf
  2155. python pdf-parser.py --object 1054 --raw --filter 00601560.pdf > malicious.js
  2156.  
  2157. cat malicious.js
  2158. -----------------------------------------------------------------------
  2159.  
  2160.  
  2161.  
  2162.  
  2163. *****Sorry - no time to cover javascript de-obfuscation today*****
  2164.  
  2165.  
  2166.  
  2167.  
  2168. ---------------------------Type This-----------------------------------
  2169. cd ~/Desktop/volatility
  2170. mkdir files2/
  2171. python vol.py -f ~/Desktop/hn_forensics.vmem dumpfiles -D files2/
  2172. python vol.py hivescan -f ~/Desktop/hn_forensics.vmem
  2173. python vol.py printkey -o 0xe1526748 -f ~/Desktop/hn_forensics.vmem Microsoft "Windows NT" CurrentVersion Winlogon
  2174. -----------------------------------------------------------------------
  2175.  
  2176.  
  2177. ######################
  2178. ----------- ############### # Intro to Reversing # ############### -----------
  2179. ######################
  2180. Lab walk-through documents are in the zip file along with the executables that need to be reversed:
  2181. https://infosecaddicts-files.s3.amazonaws.com/Lena151.zip
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187. ##############################
  2188. # Linux For InfoSec Homework #
  2189. ##############################
  2190. In order to receive your certificate of attendance you must complete the all of the quizzes on the http://linuxsurvival.com/linux-tutorial-introduction/ website.
  2191.  
  2192.  
  2193. Submit the results via email in an MS Word document with (naming convention example: YourFirstName-YourLastName-Linux-For-InfoSec-Homework.docx)
  2194.  
  2195.  
  2196.  
  2197.  
  2198. ##############################
  2199. # Linux For InfoSe Challenge #
  2200. ##############################
  2201.  
  2202. In order to receive your certificate of proficiency you must complete all of the tasks covered in the Linux For InfoSec pastebin (http://pastebin.com/eduSfPy3).
  2203.  
  2204. Submit the results via email in an MS Word document with (naming convention example: YourFirstName-YourLastName-Linux-For-InfoSec-Challenge.docx)
  2205.  
  2206.  
  2207.  
  2208.  
  2209. IMPORTANT NOTE:
  2210. Your homework/challenge must be submitted via email to both (joe-at-strategicsec-.-com and ivana-at-strategicsec-.-com) by midnight EST.
  2211.  
  2212.  
  2213. #########################################################################
  2214. # What kind of Linux am I on and how can I find out? #
  2215. # Great reference: #
  2216. # https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/ #
  2217. #########################################################################
  2218. - What’s the distribution type? What version?
  2219. -------------------------------------------
  2220. cat /etc/issue
  2221. cat /etc/*-release
  2222. cat /etc/lsb-release # Debian based
  2223. cat /etc/redhat-release # Redhat based
  2224.  
  2225.  
  2226.  
  2227. - What’s the kernel version? Is it 64-bit?
  2228. -------------------------------------------
  2229. cat /proc/version
  2230. uname -a
  2231. uname -mrs
  2232. rpm -q kernel
  2233. dmesg | grep Linux
  2234. ls /boot | grep vmlinuz-
  2235.  
  2236.  
  2237.  
  2238. - What can be learnt from the environmental variables?
  2239. ----------------------------------------------------
  2240. cat /etc/profile
  2241. cat /etc/bashrc
  2242. cat ~/.bash_profile
  2243. cat ~/.bashrc
  2244. cat ~/.bash_logout
  2245. env
  2246. set
  2247.  
  2248.  
  2249. - What services are running? Which service has which user privilege?
  2250. ------------------------------------------------------------------
  2251. ps aux
  2252. ps -ef
  2253. top
  2254. cat /etc/services
  2255.  
  2256.  
  2257. - Which service(s) are been running by root? Of these services, which are vulnerable - it’s worth a double check!
  2258. ---------------------------------------------------------------------------------------------------------------
  2259. ps aux | grep root
  2260. ps -ef | grep root
  2261.  
  2262.  
  2263.  
  2264. - What applications are installed? What version are they? Are they currently running?
  2265. ------------------------------------------------------------------------------------
  2266. ls -alh /usr/bin/
  2267. ls -alh /sbin/
  2268. dpkg -l
  2269. rpm -qa
  2270. ls -alh /var/cache/apt/archivesO
  2271. ls -alh /var/cache/yum/
  2272.  
  2273.  
  2274. - Any of the service(s) settings misconfigured? Are any (vulnerable) plugins attached?
  2275. ------------------------------------------------------------------------------------
  2276. cat /etc/syslog.conf
  2277. cat /etc/chttp.conf
  2278. cat /etc/lighttpd.conf
  2279. cat /etc/cups/cupsd.conf
  2280. cat /etc/inetd.conf
  2281. cat /etc/apache2/apache2.conf
  2282. cat /etc/my.conf
  2283. cat /etc/httpd/conf/httpd.conf
  2284. cat /opt/lampp/etc/httpd.conf
  2285. ls -aRl /etc/ | awk '$1 ~ /^.*r.*/'
  2286.  
  2287.  
  2288.  
  2289. - What jobs are scheduled?
  2290. ------------------------
  2291. crontab -l
  2292. ls -alh /var/spool/cron
  2293. ls -al /etc/ | grep cron
  2294. ls -al /etc/cron*
  2295. cat /etc/cron*
  2296. cat /etc/at.allow
  2297. cat /etc/at.deny
  2298. cat /etc/cron.allow
  2299. cat /etc/cron.deny
  2300. cat /etc/crontab
  2301. cat /etc/anacrontab
  2302. cat /var/spool/cron/crontabs/root
  2303.  
  2304.  
  2305. - Any plain text usernames and/or passwords?
  2306. ------------------------------------------
  2307. grep -i user [filename]
  2308. grep -i pass [filename]
  2309. grep -C 5 "password" [filename]
  2310. find . -name "*.php" -print0 | xargs -0 grep -i -n "var $password" # Search for Joomla passwords
  2311.  
  2312.  
  2313. - What NIC(s) does the system have? Is it connected to another network?
  2314. ---------------------------------------------------------------------
  2315. /sbin/ifconfig -a
  2316. cat /etc/network/interfaces
  2317. cat /etc/sysconfig/network
  2318.  
  2319.  
  2320. - What are the network configuration settings? What can you find out about this network? DHCP server? DNS server? Gateway?
  2321. ------------------------------------------------------------------------------------------------------------------------
  2322. cat /etc/resolv.conf
  2323. cat /etc/sysconfig/network
  2324. cat /etc/networks
  2325. iptables -L
  2326. hostname
  2327. dnsdomainname
  2328.  
  2329. - What other users & hosts are communicating with the system?
  2330. -----------------------------------------------------------
  2331. lsof -i
  2332. lsof -i :80
  2333. grep 80 /etc/services
  2334. netstat -antup
  2335. netstat -antpx
  2336. netstat -tulpn
  2337. chkconfig --list
  2338. chkconfig --list | grep 3:on
  2339. last
  2340. w
  2341.  
  2342.  
  2343.  
  2344. - Whats cached? IP and/or MAC addresses
  2345. -------------------------------------
  2346. arp -e
  2347. route
  2348. /sbin/route -nee
  2349.  
  2350.  
  2351. - Who are you? Who is logged in? Who has been logged in? Who else is there? Who can do what?
  2352. ------------------------------------------------------------------------------------------
  2353. id
  2354. who
  2355. w
  2356. last
  2357. cat /etc/passwd | cut -d: -f1 # List of users
  2358. grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}' # List of super users
  2359. awk -F: '($3 == "0") {print}' /etc/passwd # List of super users
  2360. cat /etc/sudoers
  2361. sudo -l
  2362.  
  2363.  
  2364.  
  2365. - What sensitive files can be found?
  2366. ----------------------------------
  2367. cat /etc/passwd
  2368. cat /etc/group
  2369. cat /etc/shadow
  2370. ls -alh /var/mail/
  2371.  
  2372.  
  2373.  
  2374. - Anything “interesting” in the home directorie(s)? If it’s possible to access
  2375. ----------------------------------------------------------------------------
  2376. ls -ahlR /root/
  2377. ls -ahlR /home/
  2378.  
  2379.  
  2380. - Are there any passwords in; scripts, databases, configuration files or log files? Default paths and locations for passwords
  2381. ---------------------------------------------------------------------------------------------------------------------------
  2382. cat /var/apache2/config.inc
  2383. cat /var/lib/mysql/mysql/user.MYD
  2384. cat /root/anaconda-ks.cfg
  2385.  
  2386.  
  2387. - What has the user being doing? Is there any password in plain text? What have they been edting?
  2388. -----------------------------------------------------------------------------------------------
  2389. cat ~/.bash_history
  2390. cat ~/.nano_history
  2391. cat ~/.atftp_history
  2392. cat ~/.mysql_history
  2393. cat ~/.php_history
  2394.  
  2395.  
  2396.  
  2397. - What user information can be found?
  2398. -----------------------------------
  2399. cat ~/.bashrc
  2400. cat ~/.profile
  2401. cat /var/mail/root
  2402. cat /var/spool/mail/root
  2403.  
  2404.  
  2405. - Can private-key information be found?
  2406. -------------------------------------
  2407. cat ~/.ssh/authorized_keys
  2408. cat ~/.ssh/identity.pub
  2409. cat ~/.ssh/identity
  2410. cat ~/.ssh/id_rsa.pub
  2411. cat ~/.ssh/id_rsa
  2412. cat ~/.ssh/id_dsa.pub
  2413. cat ~/.ssh/id_dsa
  2414. cat /etc/ssh/ssh_config
  2415. cat /etc/ssh/sshd_config
  2416. cat /etc/ssh/ssh_host_dsa_key.pub
  2417. cat /etc/ssh/ssh_host_dsa_key
  2418. cat /etc/ssh/ssh_host_rsa_key.pub
  2419. cat /etc/ssh/ssh_host_rsa_key
  2420. cat /etc/ssh/ssh_host_key.pub
  2421. cat /etc/ssh/ssh_host_key
  2422.  
  2423.  
  2424. - Any settings/files (hidden) on website? Any settings file with database information?
  2425. ------------------------------------------------------------------------------------
  2426. ls -alhR /var/www/
  2427. ls -alhR /srv/www/htdocs/
  2428. ls -alhR /usr/local/www/apache22/data/
  2429. ls -alhR /opt/lampp/htdocs/
  2430. ls -alhR /var/www/html/
  2431.  
  2432.  
  2433. - Is there anything in the log file(s) (Could help with “Local File Includes”!)
  2434. -----------------------------------------------------------------------------
  2435. cat /etc/httpd/logs/access_log
  2436. cat /etc/httpd/logs/access.log
  2437. cat /etc/httpd/logs/error_log
  2438. cat /etc/httpd/logs/error.log
  2439. cat /var/log/apache2/access_log
  2440. cat /var/log/apache2/access.log
  2441. cat /var/log/apache2/error_log
  2442. cat /var/log/apache2/error.log
  2443. cat /var/log/apache/access_log
  2444. cat /var/log/apache/access.log
  2445. cat /var/log/auth.log
  2446. cat /var/log/chttp.log
  2447. cat /var/log/cups/error_log
  2448. cat /var/log/dpkg.log
  2449. cat /var/log/faillog
  2450. cat /var/log/httpd/access_log
  2451. cat /var/log/httpd/access.log
  2452. cat /var/log/httpd/error_log
  2453. cat /var/log/httpd/error.log
  2454. cat /var/log/lastlog
  2455. cat /var/log/lighttpd/access.log
  2456. cat /var/log/lighttpd/error.log
  2457. cat /var/log/lighttpd/lighttpd.access.log
  2458. cat /var/log/lighttpd/lighttpd.error.log
  2459. cat /var/log/messages
  2460. cat /var/log/secure
  2461. cat /var/log/syslog
  2462. cat /var/log/wtmp
  2463. cat /var/log/xferlog
  2464. cat /var/log/yum.log
  2465. cat /var/run/utmp
  2466. cat /var/webmin/miniserv.log
  2467. cat /var/www/logs/access_log
  2468. cat /var/www/logs/access.log
  2469. ls -alh /var/lib/dhcp3/
  2470. ls -alh /var/log/postgresql/
  2471. ls -alh /var/log/proftpd/
  2472. ls -alh /var/log/samba/
  2473.  
  2474. - Note: auth.log, boot, btmp, daemon.log, debug, dmesg, kern.log, mail.info, mail.log, mail.warn, messages, syslog, udev, wtmp
  2475.  
  2476.  
  2477.  
  2478.  
  2479.  
  2480. ########################################################################################################################################
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486. ####################################
  2487. # Day 2: Building a Perfect Server #
  2488. ####################################
  2489. -------------------------------------------
  2490. Task 1: Log in to your respective Linux server
  2491. PMRF1 (Hugo/Ross)
  2492. 45.76.61.100
  2493. pmrf aegisashore
  2494.  
  2495. PMRF2 (steve/jeff)
  2496. 155.138.213.248
  2497. pmrf aegisashore
  2498.  
  2499.  
  2500. PMRF3 (elaine)
  2501. 155.138.198.202
  2502. pmrf aegisashore
  2503.  
  2504.  
  2505.  
  2506. Task 2: Build the Perfect Server
  2507. https://www.howtoforge.com/tutorial/perfect-server-centos-7-apache-mysql-php-pureftpd-postfix-dovecot-and-ispconfig/
  2508.  
  2509. Important notes:
  2510. Steps to skip
  2511. skip all of step 1
  2512. skip all of step 2
  2513. skip all of step 3
  2514. skip all of step 5
  2515.  
  2516. Important notes:
  2517. step 11 amavisd may not work. If it doesn't work just keep moving forward
  2518. ---------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement