joemccray

New Linux

Jun 6th, 2016
2,025
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.87 KB | None | 0 0
  1. ##############################
  2. # Linux For InfoSec Pros #
  3. # By Joe McCray #
  4. ##############################
  5.  
  6.  
  7. ##########################
  8. # Download the attack VM #
  9. ##########################
  10. https://s3.amazonaws.com/StrategicSec-VMs/StrategicsecUbuntu14.zip
  11. user: strategicsec
  12. pass: strategicsec
  13.  
  14.  
  15. ########################################
  16. # Boot up the StrategicSec Ubuntu host #
  17. ########################################
  18.  
  19. - Log in to your Ubuntu host with the following credentials:
  20. user: strategicsec
  21. pass: strategicsec
  22.  
  23.  
  24.  
  25. - I prefer to use Putty to SSH into my Ubuntu host on pentests and I'll be teaching this class in the same manner that I do pentests.
  26. - You can download Putty from here:
  27. - http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
  28.  
  29.  
  30.  
  31. ########################
  32. # Basic Linux Commands #
  33. ########################
  34.  
  35. pwd
  36.  
  37. whereis pwd
  38.  
  39. which pwd
  40.  
  41. sudo find / -name pwd
  42. strategicsec
  43.  
  44. /bin/pwd
  45.  
  46. mkdir test
  47.  
  48. cd test
  49.  
  50. touch one two three
  51.  
  52. ls -l t (without pressing the Enter key, press the Tab key twice. What happens?)
  53.  
  54. h (and again without pressing the Enter key, press the Tab key twice. What happens?)
  55.  
  56. Press the 'Up arrow key' (What happens?)
  57.  
  58. Press 'Ctrl-A' (What happens?)
  59.  
  60. ls
  61.  
  62. clear (What happens?)
  63.  
  64. echo one > one
  65.  
  66. cat one (What happens?)
  67.  
  68. man cat (What happens?)
  69. q
  70.  
  71. cat two
  72.  
  73. cat one > two
  74.  
  75. cat two
  76.  
  77. cat one two > three
  78.  
  79. cat three
  80.  
  81. echo four >> three
  82.  
  83. cat three (What happens?)
  84.  
  85. wc -l three
  86.  
  87. man wc
  88. q
  89.  
  90. cat three | grep four
  91.  
  92. cat three | grep one
  93.  
  94. man grep
  95. q
  96.  
  97.  
  98. sudo grep eth[01] /etc/* (What happens?)
  99. strategicsec
  100.  
  101. cat /etc/iftab
  102.  
  103.  
  104. man ps
  105. q
  106.  
  107. ps
  108.  
  109. ps aux
  110.  
  111. ps aux | less
  112.  
  113. Press the 'Up arrow key' (What happens?)
  114.  
  115. Press the 'Down arrow key' (What happens?)
  116. q
  117.  
  118. top
  119.  
  120. ############
  121. # VIM Demo #
  122. ############
  123. http://www.thegeekstuff.com/2009/03/8-essential-vim-editor-navigation-fundamentals/
  124.  
  125.  
  126.  
  127. ###################
  128. # Common commands #
  129. ###################
  130. http://www.thegeekstuff.com/2009/03/15-practical-linux-find-command-examples/
  131.  
  132. http://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples/
  133. http://www.thegeekstuff.com/2010/01/awk-introduction-tutorial-7-awk-print-examples/
  134. http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/
  135.  
  136.  
  137. http://www.thegeekstuff.com/2010/11/50-linux-commands/
  138. http://www.thegeekstuff.com/2009/10/debian-ubuntu-install-upgrade-remove-packages-using-apt-get-apt-cache-apt-file-dpkg/
  139. http://www.thegeekstuff.com/2010/11/modprobe-command-examples/
  140. http://www.thegeekstuff.com/2009/06/useradd-adduser-newuser-how-to-create-linux-users/
  141. http://www.thegeekstuff.com/2009/04/chage-linux-password-expiration-and-aging/
  142. http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
  143. http://www.thegeekstuff.com/2010/10/dmesg-command-examples/
  144. http://www.thegeekstuff.com/2010/03/netstat-command-examples/
  145. http://www.thegeekstuff.com/2009/10/debian-ubuntu-install-upgrade-remove-packages-using-apt-get-apt-cache-apt-file-dpkg/
  146.  
  147. #################
  148. # IPTables Demo #
  149. #################
  150. Reference:
  151. http://www.thegeekstuff.com/2011/06/iptables-rules-examples/
  152.  
  153. Delete Existing Rules
  154. ---------------------
  155. sudo /sbin/iptables -F
  156. strategicsec
  157.  
  158. (or)
  159.  
  160. sudo /sbin/iptables --flush
  161. strategicsec
  162.  
  163.  
  164.  
  165. Set Default Chain Policies
  166. --------------------------
  167. sudo /sbin/iptables -P INPUT DROP
  168. sudo /sbin/iptables -P FORWARD DROP
  169. sudo /sbin/iptables -P OUTPUT DROP
  170.  
  171.  
  172. Block a Specific ip-address
  173. ---------------------------
  174. BLOCK_THIS_IP="x.x.x.x"
  175. sudo /sbin/iptables -A INPUT -s "$BLOCK_THIS_IP" -j DROP
  176.  
  177.  
  178. sudo /sbin/iptables -A INPUT -i eth0 -s "$BLOCK_THIS_IP" -j DROP
  179. sudo /sbin/iptables -A INPUT -i eth0 -p tcp -s "$BLOCK_THIS_IP" -j DROP
  180.  
  181.  
  182. Allow ALL Incoming SSH
  183. ----------------------
  184. sudo /sbin/iptables -A INPUT -i eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
  185. sudo /sbin/iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
  186.  
  187.  
  188. Allow Incoming SSH only from a Sepcific Network
  189. -----------------------------------------------
  190. sudo /sbin/iptables -A INPUT -i eth0 -p tcp -s 192.168.100.0/24 --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
  191. sudo /sbin/iptables -A OUTPUT -o eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
  192.  
  193.  
  194. Allow Incoming HTTP and HTTPS
  195. -----------------------------
  196. sudo /sbin/iptables -A INPUT -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
  197. sudo /sbin/iptables -A OUTPUT -o eth0 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
  198.  
  199.  
  200. sudo /sbin/iptables -A INPUT -i eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
  201. sudo /sbin/iptables -A OUTPUT -o eth0 -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
  202.  
  203.  
  204.  
  205. Combine Multiple Rules Together using MultiPorts
  206. ------------------------------------------------
  207. sudo /sbin/iptables -A INPUT -i eth0 -p tcp -m multiport --dports 22,80,443 -m state --state NEW,ESTABLISHED -j ACCEPT
  208. sudo /sbin/iptables -A OUTPUT -o eth0 -p tcp -m multiport --sports 22,80,443 -m state --state ESTABLISHED -j ACCEPT
  209.  
  210.  
  211. Allow Outgoing SSH
  212. ------------------
  213. sudo /sbin/iptables -A OUTPUT -o eth0 -p tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
  214. sudo /sbin/iptables -A INPUT -i eth0 -p tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
  215.  
  216.  
  217.  
  218. Allow Outgoing SSH only to a Specific Network
  219.  
  220.  
  221.  
  222.  
  223.  
  224. ####################
  225. # MD5 Hashing Demo #
  226. ####################
  227. mkdir ~/demo
  228. cd ~/demo
  229.  
  230.  
  231.  
  232. mkdir hashdemo
  233. cd hashdemo
  234. echo test > test.txt
  235. cat test.txt
  236. md5sum test.txt
  237. echo hello >> test.txt
  238. cat test.txt
  239. md5sum test.txt
  240. cd ..
  241.  
  242.  
  243.  
  244. Reference:
  245. https://www.howtoforge.com/tutorial/linux-commandline-encryption-tools/
  246.  
  247.  
  248. #################################
  249. # Symmetric Key Encryption Demo #
  250. #################################
  251. md5sum test.txt
  252. mkdir gpgdemo
  253. cd gpgdemo
  254. echo test > test.txt
  255. cat test.txt
  256. gpg -c test.txt
  257. password
  258. password
  259. ls | grep test
  260. cat test.txt
  261. cat test.txt.gpg
  262. rm -rf test.txt
  263. ls | grep test
  264. gpg -o output.txt test.txt.gpg
  265.  
  266.  
  267. #########################################################################################################################
  268. # Asymmetric Key Encryption Demo #
  269. # #
  270. # Configure random number generator #
  271. # https://www.howtoforge.com/helping-the-random-number-generator-to-gain-enough-entropy-with-rng-tools-debian-lenny #
  272. #########################################################################################################################
  273.  
  274. sudo apt-get install rng-tools
  275. strategicsec
  276.  
  277. /etc/init.d/rng-tools start
  278.  
  279. sudo rngd -r /dev/urandom
  280. strategicsec
  281.  
  282.  
  283. echo hello > file1.txt
  284. echo goodbye > file2.txt
  285. echo green > file3.txt
  286. echo blue > file4.txt
  287.  
  288. tar czf files.tar.gz *.txt
  289.  
  290. gpg --gen-key
  291. 1
  292. 1024
  293. 0
  294. y
  295. John Doe
  296. --blank comment--
  297. O
  298. password
  299. password
  300.  
  301.  
  302.  
  303. gpg --armor --output file-enc-pubkey.txt --export 'John Doe'
  304.  
  305. cat file-enc-pubkey.txt
  306.  
  307. gpg --armor --output file-enc-privkey.asc --export-secret-keys 'John Doe'
  308.  
  309. cat file-enc-privkey.asc
  310.  
  311. gpg --encrypt --recipient 'John Doe' files.tar.gz
  312.  
  313. rm -rf files.tar.gz *.txt
  314.  
  315. tar -zxvf files.tar.gz.gpg
  316.  
  317. gpg --output output.tar.gz --decrypt files.tar.gz.gpg
  318. password
  319.  
  320. tar -zxvf output.tar.gz
  321.  
  322.  
  323. Reference:
  324. http://linoxide.com/security/gpg-comand-linux-how-to-encrypt-and-decrypt-file/
  325.  
  326.  
  327.  
  328. ############################
  329. # Encryption using OpenSSL #
  330. ############################
  331. openssl genrsa -out private_key.pem 1024
  332. openssl rsa -in private_key.pem -out public_key.pem -outform PEM -pubout
  333.  
  334.  
  335. echo hello > encrypt.txt
  336. openssl rsautl -encrypt -inkey public_key.pem -pubin -in encrypt.txt -out encrypt.dat
  337.  
  338. cat encrypt.dat
  339.  
  340. rm -rf encrypt.txt
  341.  
  342. openssl rsautl -decrypt -inkey private_key.pem -in encrypt.dat -out decrypt.txt
  343.  
  344. cat decrypt.txt
  345.  
  346.  
  347. ##################
  348. # SELinux Basics #
  349. ##################
  350.  
  351. sudo apt-get install selinux selinux-utils
  352. strategicsec
  353.  
  354.  
  355. - Change the SELinux mode in /etc/selinux/config (optional):
  356.  
  357. - Enforcing
  358. sudo sed -i 's/SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config
  359. strategicsec
  360.  
  361. - Permissive
  362. sudo sed -i 's/SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
  363. strategicsec
  364.  
  365. - Reboot
  366.  
  367. Reference:
  368. http://www.techrepublic.com/blog/linux-and-open-source/practical-selinux-for-the-beginner-contexts-and-labels/
  369.  
  370.  
  371. ############
  372. # AppArmor #
  373. ############
  374. Reference:
  375. http://www.thegeekstuff.com/2014/03/apparmor-ubuntu/
  376.  
  377.  
  378.  
  379.  
  380. ########################
  381. # Bash Shell Scripting #
  382. ########################
  383. http://www.thegeekstuff.com/2011/07/bash-for-loop-examples/
  384. http://www.thegeekstuff.com/2010/07/bash-string-manipulation/
  385. http://www.thegeekstuff.com/2012/05/encrypt-bash-shell-script/
  386.  
  387.  
  388.  
  389.  
  390. ############################
  391. # Ubuntu Server Build Task #
  392. ############################
  393. https://www.howtoforge.com/tutorial/perfect-server-ubuntu-16.04-with-apache-php-myqsl-pureftpd-bind-postfix-doveot-and-ispconfig/
  394.  
  395. ############################
  396. # CentOS Server Build Task #
  397. ############################
  398. https://www.howtoforge.com/tutorial/perfect-server-centos-7-1-apache-mysql-php-pureftpd-postfix-dovecot-and-ispconfig3/
  399.  
  400.  
  401.  
  402.  
  403. #########################################################################
  404. # What kind of Linux am I on and how can I find out? #
  405. # Great reference: #
  406. # https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/ #
  407. #########################################################################
  408. What’s the distribution type? What version?
  409. -------------------------------------------
  410. cat /etc/issue
  411. cat /etc/*-release
  412. cat /etc/lsb-release # Debian based
  413. cat /etc/redhat-release # Redhat based
  414.  
  415.  
  416.  
  417. What’s the kernel version? Is it 64-bit?
  418. -------------------------------------------
  419. cat /proc/version
  420. uname -a
  421. uname -mrs
  422. rpm -q kernel
  423. dmesg | grep Linux
  424. ls /boot | grep vmlinuz-
  425.  
  426.  
  427.  
  428. What can be learnt from the environmental variables?
  429. ----------------------------------------------------
  430. cat /etc/profile
  431. cat /etc/bashrc
  432. cat ~/.bash_profile
  433. cat ~/.bashrc
  434. cat ~/.bash_logout
  435. env
  436. set
  437.  
  438.  
  439. What services are running? Which service has which user privilege?
  440. ------------------------------------------------------------------
  441. ps aux
  442. ps -ef
  443. top
  444. cat /etc/services
  445.  
  446.  
  447. Which service(s) are been running by root? Of these services, which are vulnerable - it’s worth a double check!
  448. ---------------------------------------------------------------------------------------------------------------
  449. ps aux | grep root
  450. ps -ef | grep root
  451.  
  452.  
  453.  
  454. What applications are installed? What version are they? Are they currently running?
  455. ------------------------------------------------------------------------------------
  456. ls -alh /usr/bin/
  457. ls -alh /sbin/
  458. dpkg -l
  459. dpkg --get-selections | grep -v deinstall
  460. rpm -qa
  461. ls -alh /var/cache/apt/archives
  462. ls -alh /var/cache/yum/
  463.  
  464.  
  465. Any of the service(s) settings misconfigured? Are any (vulnerable) plugins attached?
  466. ------------------------------------------------------------------------------------
  467. cat /etc/syslog.conf
  468. cat /etc/chttp.conf
  469. cat /etc/lighttpd.conf
  470. cat /etc/cups/cupsd.conf
  471. cat /etc/inetd.conf
  472. cat /etc/apache2/apache2.conf
  473. cat /etc/my.conf
  474. cat /etc/httpd/conf/httpd.conf
  475. cat /opt/lampp/etc/httpd.conf
  476. ls -aRl /etc/ | awk '$1 ~ /^.*r.*/'
  477.  
  478.  
  479.  
  480. What jobs are scheduled?
  481. ------------------------
  482. crontab -l
  483. ls -alh /var/spool/cron
  484. ls -al /etc/ | grep cron
  485. ls -al /etc/cron*
  486. cat /etc/cron*
  487. cat /etc/at.allow
  488. cat /etc/at.deny
  489. cat /etc/cron.allow
  490. cat /etc/cron.deny
  491. cat /etc/crontab
  492. cat /etc/anacrontab
  493. cat /var/spool/cron/crontabs/root
  494.  
  495.  
  496. Any plain text usernames and/or passwords?
  497. ------------------------------------------
  498. grep -i user [filename]
  499. grep -i pass [filename]
  500. grep -C 5 "password" [filename]
  501. find . -name "*.php" -print0 | xargs -0 grep -i -n "var $password" # Search for Joomla passwords
  502.  
  503.  
  504. What NIC(s) does the system have? Is it connected to another network?
  505. ---------------------------------------------------------------------
  506. /sbin/ifconfig -a
  507. cat /etc/network/interfaces
  508. cat /etc/sysconfig/network
  509.  
  510.  
  511. What are the network configuration settings? What can you find out about this network? DHCP server? DNS server? Gateway?
  512. ------------------------------------------------------------------------------------------------------------------------
  513. cat /etc/resolv.conf
  514. cat /etc/sysconfig/network
  515. cat /etc/networks
  516. sudo iptables -L
  517. hostname
  518. dnsdomainname
  519.  
  520. What other users & hosts are communicating with the system?
  521. -----------------------------------------------------------
  522. lsof -i
  523. lsof -i :80
  524. grep 80 /etc/services
  525. netstat -antup
  526. netstat -antpx
  527. netstat -tulpn
  528. chkconfig --list
  529. chkconfig --list | grep 3:on
  530. last
  531. w
  532.  
  533.  
  534.  
  535. Whats cached? IP and/or MAC addresses
  536. -------------------------------------
  537. arp -e
  538. route
  539. /sbin/route -nee
  540.  
  541.  
  542. Who are you? Who is logged in? Who has been logged in? Who else is there? Who can do what?
  543. ------------------------------------------------------------------------------------------
  544. id
  545. who
  546. w
  547. last
  548. cat /etc/passwd | cut -d: # List of users
  549. grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}' # List of super users
  550. awk -F: '($3 == "0") {print}' /etc/passwd # List of super users
  551. sudo cat /etc/sudoers
  552. sudo -l
  553.  
  554.  
  555.  
  556. What sensitive files can be found?
  557. ----------------------------------
  558. cat /etc/passwd
  559. cat /etc/group
  560. sudo cat /etc/shadow
  561. ls -alh /var/mail/
  562.  
  563.  
  564.  
  565. Anything “interesting” in the home directorie(s)? If it’s possible to access
  566. ----------------------------------------------------------------------------
  567. ls -ahlR /root/
  568. ls -ahlR /home/
  569.  
  570.  
  571. Are there any passwords in; scripts, databases, configuration files or log files? Default paths and locations for passwords
  572. ---------------------------------------------------------------------------------------------------------------------------
  573. cat /var/apache2/config.inc
  574. cat /var/lib/mysql/mysql/user.MYD
  575. sudo cat /root/anaconda-ks.cfg
  576.  
  577.  
  578. What has the user being doing? Is there any password in plain text? What have they been edting?
  579. -----------------------------------------------------------------------------------------------
  580. cat ~/.bash_history
  581. cat ~/.nano_history
  582. cat ~/.atftp_history
  583. cat ~/.mysql_history
  584. cat ~/.php_history
  585.  
  586.  
  587.  
  588. What user information can be found?
  589. -----------------------------------
  590. cat ~/.bashrc
  591. cat ~/.profile
  592. cat /var/mail/root
  593. cat /var/spool/mail/root
  594.  
  595.  
  596. Can private-key information be found?
  597. -------------------------------------
  598. cat ~/.ssh/authorized_keys
  599. cat ~/.ssh/identity.pub
  600. cat ~/.ssh/identity
  601. cat ~/.ssh/id_rsa.pub
  602. cat ~/.ssh/id_rsa
  603. cat ~/.ssh/id_dsa.pub
  604. cat ~/.ssh/id_dsa
  605. cat /etc/ssh/ssh_config
  606. cat /etc/ssh/sshd_config
  607. cat /etc/ssh/ssh_host_dsa_key.pub
  608. cat /etc/ssh/ssh_host_dsa_key
  609. cat /etc/ssh/ssh_host_rsa_key.pub
  610. cat /etc/ssh/ssh_host_rsa_key
  611. cat /etc/ssh/ssh_host_key.pub
  612. cat /etc/ssh/ssh_host_key
  613.  
  614.  
  615. Any settings/files (hidden) on website? Any settings file with database information?
  616. ------------------------------------------------------------------------------------
  617. ls -alhR /var/www/
  618. ls -alhR /srv/www/htdocs/
  619. ls -alhR /usr/local/www/apache22/data/
  620. ls -alhR /opt/lampp/htdocs/
  621. ls -alhR /var/www/html/
  622.  
  623.  
  624. Is there anything in the log file(s) (Could help with “Local File Includes”!)
  625. -----------------------------------------------------------------------------
  626. cat /etc/httpd/logs/access_log
  627. cat /etc/httpd/logs/access.log
  628. cat /etc/httpd/logs/error_log
  629. cat /etc/httpd/logs/error.log
  630. cat /var/log/apache2/access_log
  631. cat /var/log/apache2/access.log
  632. cat /var/log/apache2/error_log
  633. cat /var/log/apache2/error.log
  634. cat /var/log/apache/access_log
  635. cat /var/log/apache/access.log
  636. cat /var/log/auth.log
  637. cat /var/log/chttp.log
  638. cat /var/log/cups/error_log
  639. cat /var/log/dpkg.log
  640. cat /var/log/faillog
  641. cat /var/log/httpd/access_log
  642. cat /var/log/httpd/access.log
  643. cat /var/log/httpd/error_log
  644. cat /var/log/httpd/error.log
  645. cat /var/log/lastlog
  646. cat /var/log/lighttpd/access.log
  647. cat /var/log/lighttpd/error.log
  648. cat /var/log/lighttpd/lighttpd.access.log
  649. cat /var/log/lighttpd/lighttpd.error.log
  650. cat /var/log/messages
  651. cat /var/log/secure
  652. cat /var/log/syslog
  653. cat /var/log/wtmp
  654. cat /var/log/xferlog
  655. cat /var/log/yum.log
  656. cat /var/run/utmp
  657. cat /var/webmin/miniserv.log
  658. cat /var/www/logs/access_log
  659. cat /var/www/logs/access.log
  660. ls -alh /var/lib/dhcp3/
  661. ls -alh /var/log/postgresql/
  662. ls -alh /var/log/proftpd/
  663. ls -alh /var/log/samba/
  664.  
  665. Note: auth.log, boot, btmp, daemon.log, debug, dmesg, kern.log, mail.info, mail.log, mail.warn, messages, syslog, udev, wtmp
  666.  
  667.  
  668. ###########################
  669. # Target IP Determination #
  670. ###########################
  671. - This portion starts the actual workshop content
  672. - Zone Transfer fails on most domains, but here is an example of one that works:
  673. dig axfr heartinternet.co.uk @ns.heartinternet.co.uk
  674.  
  675.  
  676. - Usually you will need to do a DNS brute-force with something like blindcrawl or fierce
  677. perl blindcrawl.pl -d motorola.com
  678. Look up the IP addresses at:
  679. http://www.networksolutions.com/whois/index.jsp
  680.  
  681.  
  682. - Note: If you are on a different machine and need to download blindcrawl can you download it this way:
  683. wget dl.packetstormsecurity.net/UNIX/scanners/blindcrawl.pl
  684. chmod +x blindcrawl.pl
  685.  
  686.  
  687.  
  688. cd ~/toolz/fierce2
  689. sudo apt-get install -y cpanminus cpan-listchanges cpanoutdated libappconfig-perl libyaml-appconfig-perl libnetaddr-ip-perl libnet-cidr-perl vim subversion
  690. strategicsec
  691.  
  692.  
  693. - Note: Only run this 'svn co' command below if you are NOT on the strategicsec VM:
  694. svn co https://svn.assembla.com/svn/fierce/fierce2/trunk/ fierce2/
  695.  
  696.  
  697. cd ~/toolz/fierce2
  698. wget http://search.cpan.org/CPAN/authors/id/A/AB/ABW/Template-Toolkit-2.14.tar.gz
  699. tar -zxvf Template-Toolkit-2.14.tar.gz
  700. cd Template-Toolkit-2.14/
  701. perl Makefile.PL
  702. y
  703. y
  704. n
  705. y
  706. sudo make install
  707. strategicsec
  708.  
  709. cd ..
  710.  
  711. sudo bash install.sh
  712. strategicsec
  713.  
  714. ./fierce
  715.  
  716. ./fierce -dns motorola.com
  717.  
  718. cd ~/toolz/
  719.  
  720. - Note: Only run these 'wget, gcc, chmod' commands below if you are NOT on the strategicsec VM:
  721. wget https://raw.githubusercontent.com/BenDrysdale/ipcrawl/master/ipcrawl.c
  722. gcc -o ipcrawl ipcrawl.c
  723. chmod +x ipcrawl
  724.  
  725.  
  726.  
  727. - Here we do a forward lookup against an entire IP range. Basically take every IP in the range and see what it's hostname is
  728. cd ~/toolz/
  729. ./ipcrawl 148.87.1.1 148.87.1.254 (DNS forward lookup against an IP range)
  730.  
  731.  
  732. sudo nmap -sL 148.87.1.0-255
  733. strategicsec
  734.  
  735. sudo nmap -sL 148.87.1.0-255 | grep oracle
  736. strategicsec
  737.  
  738. - Reference: http://blog.depthsecurity.com/2012/01/obtaining-hostdomain-names-through-ssl.html
  739. sudo nmap -p 443,444,8443,8080,8088 --script=ssl-cert --open 144.189.100.1-254
  740. strategicsec
  741.  
  742.  
  743.  
  744.  
  745. ###########################
  746. # Load Balancer Detection #
  747. ###########################
  748.  
  749. - Here are some options to use for identifying load balancers:
  750. - http://toolbar.netcraft.com/site_report/
  751. - Firefox LiveHTTP Headers
  752.  
  753.  
  754. - Here are some command-line options to use for identifying load balancers:
  755.  
  756. dig google.com
  757.  
  758. cd ~/toolz
  759. ./lbd-0.1.sh google.com
  760.  
  761.  
  762. halberd microsoft.com
  763. halberd motorola.com
  764. halberd oracle.com
  765.  
  766.  
  767.  
  768.  
  769.  
  770. ######################################
  771. # Web Application Firewall Detection #
  772. ######################################
  773.  
  774. cd ~/toolz/wafw00f
  775. python wafw00f.py http://www.oracle.com
  776. python wafw00f.py http://www.strategicsec.com
  777.  
  778.  
  779. cd ~/toolz/
  780. sudo nmap -p 80 --script http-waf-detect.nse oracle.com
  781. strategicsec
  782.  
  783. sudo nmap -p 80 --script http-waf-detect.nse healthcare.gov
  784. strategicsec
  785.  
  786.  
  787. #########################
  788. # Playing with Nmap NSE #
  789. #########################
  790.  
  791. nmap -Pn -p80 --script ip-geolocation-* strategicsec.com
  792.  
  793. nmap -p80 --script dns-brute strategicsec.com
  794.  
  795. nmap --script http-robtex-reverse-ip secore.info
  796.  
  797. nmap -Pn -p80 --script=http-headers strategicsec.com
  798.  
  799.  
  800. ls /usr/share/nmap/scripts | grep http
  801. nmap -Pn -p80 --script=http-* strategicsec.com
  802.  
  803. ############
  804. # Nmap NSE #
  805. ############
  806.  
  807. - Reference for this tutorial is:
  808. https://thesprawl.org/research/writing-nse-scripts-for-vulnerability-scanning/
  809.  
  810. ----------------------------------------------------------------------
  811. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  812. strategicsec
  813.  
  814.  
  815.  
  816. -- The Head Section --
  817. -- The Rule Section --
  818. portrule = function(host, port)
  819. return port.protocol == "tcp"
  820. and port.number == 80
  821. and port.state == "open"
  822. end
  823.  
  824. -- The Action Section --
  825. action = function(host, port)
  826. return "I love Linux!"
  827. end
  828. ----------------------------------------------------------------------
  829.  
  830. - Ok, now that we've made that change let's run the script
  831. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse strategicsec.com -p 22,80,443
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838. ----------------------------------------------------------------------
  839. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  840.  
  841. -- The Head Section --
  842. local shortport = require "shortport"
  843.  
  844. -- The Rule Section --
  845. portrule = shortport.http
  846.  
  847.  
  848. -- The Action Section --
  849. action = function(host, port)
  850. return "I still love Linux!"
  851. end
  852. ----------------------------------------------------------------------
  853.  
  854. - Ok, now that we've made that change let's run the script
  855. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse strategicsec.com -p 22,80,443
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863. OK, now let's have some fun with my buddy Carlos Perez's website which you should have been looking at quite a lot if you were trying to get Ruby 2.1.5 working.
  864.  
  865. ----------------------------------------------------------------------
  866. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  867.  
  868. -- The Head Section --
  869. local shortport = require "shortport"
  870. local http = require "http"
  871.  
  872. -- The Rule Section --
  873. portrule = shortport.http
  874.  
  875. -- The Action Section --
  876. action = function(host, port)
  877.  
  878. local uri = "/installing-metasploit-in-ubunt/"
  879. local response = http.get(host, port, uri)
  880. return response.status
  881.  
  882. end
  883. ----------------------------------------------------------------------
  884.  
  885. - Ok, now that we've made that change let's run the script
  886. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
  887.  
  888.  
  889.  
  890.  
  891. ----------------------------------------------------------------------
  892. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  893.  
  894. -- The Head Section --
  895. local shortport = require "shortport"
  896. local http = require "http"
  897.  
  898. -- The Rule Section --
  899. portrule = shortport.http
  900.  
  901. -- The Action Section --
  902. action = function(host, port)
  903.  
  904. local uri = "/installing-metasploit-in-ubunt/"
  905. local response = http.get(host, port, uri)
  906.  
  907. if ( response.status == 200 ) then
  908. return response.body
  909. end
  910.  
  911. end
  912. ----------------------------------------------------------------------
  913.  
  914. - Ok, now that we've made that change let's run the script
  915. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925. ----------------------------------------------------------------------
  926. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  927.  
  928. -- The Head Section --
  929. local shortport = require "shortport"
  930. local http = require "http"
  931. local string = require "string"
  932.  
  933. -- The Rule Section --
  934. portrule = shortport.http
  935.  
  936. -- The Action Section --
  937. action = function(host, port)
  938.  
  939. local uri = "/installing-metasploit-in-ubunt/"
  940. local response = http.get(host, port, uri)
  941.  
  942. if ( response.status == 200 ) then
  943. local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian")
  944. return title
  945. end
  946.  
  947. end
  948. ----------------------------------------------------------------------
  949.  
  950. - Ok, now that we've made that change let's run the script
  951. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959. ----------------------------------------------------------------------
  960. sudo vi /usr/share/nmap/scripts/intro-nse.nse
  961.  
  962. -- The Head Section --
  963. local shortport = require "shortport"
  964. local http = require "http"
  965. local string = require "string"
  966.  
  967. -- The Rule Section --
  968. portrule = shortport.http
  969.  
  970. -- The Action Section --
  971. action = function(host, port)
  972.  
  973. local uri = "/installing-metasploit-in-ubunt/"
  974. local response = http.get(host, port, uri)
  975.  
  976. if ( response.status == 200 ) then
  977. local title = string.match(response.body, "Installing Metasploit in Ubuntu and Debian")
  978.  
  979. if (title) then
  980. return "Vulnerable"
  981. else
  982. return "Not Vulnerable"
  983. end
  984. end
  985. end
  986.  
  987. ----------------------------------------------------------------------
  988.  
  989. - Ok, now that we've made that change let's run the script
  990. sudo nmap --script=/usr/share/nmap/scripts/intro-nse.nse darkoperator.com -p 22,80,443
  991.  
  992.  
  993.  
  994. ####################
  995. # Installing Scapy #
  996. ####################
  997.  
  998. sudo apt-get update
  999. sudo apt-get install python-scapy python-pyx python-gnuplot
  1000.  
  1001.  
  1002. - Reference Page For All Of The Commands We Will Be Running:
  1003. http://samsclass.info/124/proj11/proj17-scapy.html
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009. - To run Scapy interactively
  1010.  
  1011. sudo scapy
  1012.  
  1013.  
  1014.  
  1015. #####################################
  1016. # Sending ICMPv4 Packets with scapy #
  1017. #####################################
  1018.  
  1019. - In the Linux machine, in the Terminal window, at the >>> prompt, type this command, and then press the Enter key:
  1020.  
  1021. i = IP()
  1022.  
  1023.  
  1024.  
  1025.  
  1026. - This creates an object named i of type IP. To see the properties of that object, use the display() method with this command:
  1027.  
  1028. i.display()
  1029.  
  1030.  
  1031.  
  1032.  
  1033. - Use these commands to set the destination IP address and display the properties of the i object again. Replace the IP address in the first command with the IP address of your target Windows machine:
  1034.  
  1035. i.dst="192.168.54.184"
  1036.  
  1037. i.display()
  1038.  
  1039.  
  1040.  
  1041.  
  1042. - Notice that scapy automatically fills in your machine's source IP address.
  1043.  
  1044. - Use these commands to create an object named ic of type ICMP and display its properties:
  1045.  
  1046.  
  1047. ic = ICMP()
  1048.  
  1049. ic.display()
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055. - Use this command to send the packet onto the network and listen to a single packet in response. Note that the third character is the numeral 1, not a lowercase L:
  1056.  
  1057. sr1(i/ic)
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063. - This command sends and receives one packet, of type IP at layer 3 and ICMP at layer 4.
  1064.  
  1065.  
  1066. - The Padding section shows the portion of the packet that carries higher-level data. In this case it contains only zeroes as padding.
  1067.  
  1068. - Use this command to send a packet that is IP at layer 3, ICMP at layer 4, and that contains data with your name in it (replace YOUR NAME with your own name):
  1069.  
  1070.  
  1071. sr1(i/ic/"YOUR NAME")
  1072.  
  1073.  
  1074. - You should see a reply with a Raw section containing your name.
  1075.  
  1076.  
  1077.  
  1078. ###################################
  1079. # Sending a UDP Packet with Scapy #
  1080. ###################################
  1081.  
  1082.  
  1083. - Preparing the Target
  1084. $ ncat -ulvp 4444
  1085.  
  1086.  
  1087.  
  1088.  
  1089. --open another terminal--
  1090. In the Linux machine, in the Terminal window, at the >>> prompt, type these commands, and then press the Enter key:
  1091.  
  1092. u = UDP()
  1093.  
  1094. u.display()
  1095.  
  1096.  
  1097.  
  1098. - This creates an object named u of type UDP, and displays its properties.
  1099.  
  1100. - Execute these commands to change the destination port to 4444 and display the properties again:
  1101.  
  1102. i.dst="192.168.54.184" <--- replace this with a host that you can run netcat on (ex: another VM or your host computer)
  1103.  
  1104. u.dport = 4444
  1105.  
  1106. u.display()
  1107.  
  1108.  
  1109.  
  1110. - Execute this command to send the packet to the Windows machine:
  1111.  
  1112. send(i/u/"YOUR NAME SENT VIA UDP\n")
  1113.  
  1114.  
  1115.  
  1116. - On the Windows target, you should see the message appear
  1117.  
  1118.  
  1119. p = sr1(IP(dst="8.8.8.8")/UDP()/DNS(rd=1,qd=DNSQR(qname="strategicsec.com")))
  1120.  
  1121.  
  1122. p=sr(IP(dst="192.168.230.2")/TCP(dport=[23,80,53,443]))
  1123.  
  1124.  
  1125. p=sr(IP(dst="192.168.230.2")/TCP(dport=[80]))
  1126.  
  1127.  
  1128. traceroute (["strategicsec.com"], maxttl=20)
  1129. This is actually an ICMP & TCP traceroute, default destination is port 80
  1130.  
  1131.  
  1132. traceroute (["strategicsec.com"], dport=443, maxttl=20)
  1133.  
  1134.  
  1135.  
  1136. ############################
  1137. # Ping Sweeping with Scapy #
  1138. ############################
  1139.  
  1140. ----------------------------------------------------------------------
  1141. vi scapy-pingsweep.py
  1142.  
  1143.  
  1144. #!/usr/bin/python
  1145. from scapy.all import *
  1146.  
  1147. TIMEOUT = 2
  1148. conf.verb = 0
  1149. for ip in range(0, 256):
  1150. packet = IP(dst="192.168.1." + str(ip), ttl=20)/ICMP()
  1151. reply = sr1(packet, timeout=TIMEOUT)
  1152. if not (reply is None):
  1153. print reply.dst, "is online"
  1154. else:
  1155. print "Timeout waiting for %s" % packet[IP].dst
  1156. ----------------------------------------------------------------------
  1157.  
  1158.  
  1159. ###############################################
  1160. # Checking out some scapy based port scanners #
  1161. ###############################################
  1162.  
  1163. wget https://s3.amazonaws.com/SecureNinja/Python/rdp_scan.py
  1164.  
  1165. cat rdp_scan.py
  1166.  
  1167. sudo python rdp_scan.py 192.168.1.250
  1168.  
  1169.  
  1170.  
  1171. Log in to your Ubuntu system with the username 'malware' and the password 'malware'.
  1172.  
  1173. After logging please open a terminal window and type the following commands:
  1174.  
  1175. cd Desktop/
  1176.  
  1177.  
  1178. This is actual Malware (remmeber to run it in a VM - the password to extract it is 'infected':
  1179.  
  1180. wget https://s3.amazonaws.com/StrategicSec-Files/MalwareAnalysis/malware-password-is-infected.zip
  1181. wget http://www.beenuarora.com/code/analyse_malware.py
  1182.  
  1183. unzip malware-password-is-infected.zip
  1184. infected
  1185.  
  1186. file malware.exe
  1187.  
  1188. mv malware.exe malware.pdf
  1189.  
  1190. file malware.pdf
  1191.  
  1192. mv malware.pdf malware.exe
  1193.  
  1194. hexdump -n 2 -C malware.exe
  1195.  
  1196. ***What is '4d 5a' or 'MZ'***
  1197. Reference: http://www.garykessler.net/library/file_sigs.html
  1198.  
  1199.  
  1200. objdump -x malware.exe
  1201.  
  1202. strings malware.exe
  1203.  
  1204. strings --all malware.exe | head -n 6
  1205.  
  1206. strings malware.exe | grep -i dll
  1207.  
  1208. strings malware.exe | grep -i library
  1209.  
  1210. strings malware.exe | grep -i reg
  1211.  
  1212. strings malware.exe | grep -i hkey
  1213.  
  1214. strings malware.exe | grep -i hku
  1215.  
  1216. - We didn't see anything like HKLM, HKCU or other registry type stuff
  1217.  
  1218. strings malware.exe | grep -i irc
  1219.  
  1220. strings malware.exe | grep -i join
  1221.  
  1222. strings malware.exe | grep -i admin
  1223.  
  1224. strings malware.exe | grep -i list
  1225.  
  1226.  
  1227. - List of IRC commands: https://en.wikipedia.org/wiki/List_of_Internet_Relay_Chat_commands
  1228. sudo apt-get install -y python-pefile
  1229.  
  1230. vi analyse_malware.py
  1231.  
  1232. python analyse_malware.py malware.exe
  1233.  
  1234.  
  1235. Here is a 2 million sample malware DB created by Derek Morton that you can use to start your DB with:
  1236. http://derekmorton.name/files/malware_12-14-12.sql.bz2
  1237.  
  1238.  
  1239. Malware Repositories:
  1240. http://malshare.com/index.php
  1241. http://www.malwareblacklist.com/
  1242. http://www.virusign.com/
  1243. http://virusshare.com/
  1244. http://www.tekdefense.com/downloads/malware-samples/
  1245.  
  1246. ###############################
  1247. # Creating a Malware Database #
  1248. ###############################
  1249.  
  1250. Creating a malware database (sqlite)
  1251. ------------------------------------
  1252. wget https://malwarecookbook.googlecode.com/svn/trunk/4/4/avsubmit.py
  1253. wget https://s3.amazonaws.com/StrategicSec-Files/MalwareAnalysis/malware-password-is-infected.zip
  1254. unzip malware-password-is-infected.zip
  1255. infected
  1256. python avsubmit.py --init
  1257. python avsubmit.py -f malware.exe -e
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263. Creating a malware database (mysql)
  1264. -----------------------------------
  1265. Step 1: Installing MySQL database
  1266. Run the following command in the terminal:
  1267.  
  1268. sudo apt-get install mysql-server
  1269.  
  1270. Step 2: Installing Python MySQLdb module
  1271. Run the following command in the terminal:
  1272.  
  1273. sudo apt-get build-dep python-mysqldb
  1274. sudo apt-get install python-mysqldb
  1275.  
  1276. Step 3: Logging in
  1277. Run the following command in the terminal:
  1278.  
  1279. mysql -u root -p (set a password of 'malware')
  1280.  
  1281. Then create one database by running following command:
  1282.  
  1283. create database malware;
  1284.  
  1285.  
  1286.  
  1287. wget https://raw.githubusercontent.com/dcmorton/MalwareTools/master/mal_to_db.py
  1288.  
  1289. vi mal_to_db.py -i (fill in database connection information)
  1290.  
  1291. python mal_to_db.py -i
  1292.  
  1293. python mal_to_db.py -i -f malware.exe -u
  1294.  
  1295.  
  1296. mysql -u root -p
  1297. malware
  1298.  
  1299. mysql> use malware;
  1300.  
  1301. select id,md5,sha1,sha256,time FROM files;
  1302.  
  1303. mysql> quit;
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309. ##############################
  1310. # Lesson 32: Setting up Yara #
  1311. ##############################
  1312.  
  1313.  
  1314. sudo apt-get install clamav clamav-freshclam
  1315.  
  1316. sudo freshclam
  1317.  
  1318. sudo Clamscan
  1319.  
  1320. sudo apt-get install libpcre3 libpcre3-dev
  1321.  
  1322. wget https://github.com/plusvic/yara/archive/v3.1.0.tar.gz
  1323.  
  1324. wget http://yara-project.googlecode.com/files/yara-python-1.4.tar.gz
  1325.  
  1326. tar -zxvf v3.1.0.tar.gz
  1327.  
  1328. cd yara-3.1.0/
  1329.  
  1330. ./bootstrap.sh
  1331.  
  1332. ./configure
  1333.  
  1334. make
  1335.  
  1336. make check
  1337.  
  1338. sudo make install
  1339.  
  1340. cd yara-python/
  1341.  
  1342. python setup.py build
  1343.  
  1344. sudo python setup.py install
  1345.  
  1346. cd ..
  1347.  
  1348. yara -v
  1349.  
  1350. wget https://malwarecookbook.googlecode.com/svn-history/r5/trunk/3/3/clamav_to_yara.py
  1351.  
  1352. sigtool -u /var/lib/clamav/main.cvd
  1353.  
  1354. python clamav_to_yara.py -f main.ndb -o clamav.yara
  1355.  
  1356. wget https://s3.amazonaws.com/StrategicSec-Files/MalwareAnalysis/malware-password-is-infected.zip
  1357.  
  1358. unzip malware-password-is-infected.zip
  1359. infected
  1360.  
  1361. mkdir malcode/
  1362.  
  1363. mv malware.exe malcode/
  1364.  
  1365. vi testrule.yara
  1366. ----------------
  1367. rule IsPE
  1368. {
  1369. meta:
  1370. description = "Windows executable file"
  1371.  
  1372. condition:
  1373. // MZ signature at offset 0 and ...
  1374. uint16(0) == 0x5A4D and
  1375. // ... PE signature at offset stored in MZ header at 0x3C
  1376. uint32(uint32(0x3C)) == 0x00004550
  1377. }
  1378.  
  1379. rule has_no_DEP
  1380. {
  1381. meta:
  1382. description = "DEP is not enabled"
  1383.  
  1384. condition:
  1385. IsPE and
  1386. uint16(uint32(0x3C)+0x5E) & 0x00100 == 0
  1387. }
  1388.  
  1389. rule has_no_ASLR
  1390. {
  1391. meta:
  1392. description = "ASLR is not enabled"
  1393.  
  1394. condition:
  1395. IsPE and
  1396. uint16(uint32(0x3C)+0x5E) & 0x0040 == 0
  1397. }
  1398. ----------------
  1399.  
  1400.  
  1401. yara testrule.yara malcode/malware.exe
  1402.  
  1403. mkdir rules/
  1404.  
  1405. cd rules/
  1406.  
  1407. wget https://malwarecookbook.googlecode.com/svn-history/r5/trunk/3/5/capabilities.yara
  1408.  
  1409. wget https://malwarecookbook.googlecode.com/svn-history/r5/trunk/3/6/magic.yara
  1410.  
  1411. wget https://malwarecookbook.googlecode.com/svn-history/r5/trunk/3/4/packer.yara
  1412.  
  1413. cd ..
  1414.  
  1415. yara rules/ malcode/malware.exe
  1416.  
  1417. wget https://github.com/Xen0ph0n/YaraGenerator/archive/master.zip
  1418.  
  1419. unzip master.zip
  1420.  
  1421. cd YaraGenerator-master/
  1422.  
  1423. python yaraGenerator.py ../malcode/ -r Test-Rule-2 -a "Joe McCray" -d "Test Rule Made With Yara Generator" -t "TEST" -f "exe"
  1424.  
  1425. cat Test-Rule-2.yar
  1426.  
  1427. wget http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
  1428.  
  1429. yara Test-Rule-2.yar putty.exe
  1430.  
  1431.  
  1432.  
  1433.  
  1434. ####################
  1435. # Additional Tasks #
  1436. ####################
  1437.  
  1438. - PE Scanner:
  1439. https://malwarecookbook.googlecode.com/svn/trunk/3/8/pescanner.py
  1440. http://www.beenuarora.com/code/analyse_malware.py
  1441.  
  1442. - AV submission:
  1443. http://malwarecookbook.googlecode.com/svn/trunk/4/4/avsubmit.py
  1444. https://raw.githubusercontent.com/dcmorton/MalwareTools/master/vtsubmit.py
  1445.  
  1446. - Malware Database Creation:
  1447. https://raw.githubusercontent.com/dcmorton/MalwareTools/master/mal_to_db.py
  1448.  
  1449.  
  1450.  
  1451.  
  1452. cd /home/malware/Desktop/Browser\ Forensics
  1453.  
  1454. ls | grep pcap
  1455.  
  1456. perl chaosreader.pl suspicious-time.pcap
  1457.  
  1458. firefox index.html
  1459.  
  1460. cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)"
  1461.  
  1462. cat index.text | grep -v '"' | grep -oE "([0-9]+\.){3}[0-9]+.*\)" | awk '{print $4, $5, $6}' | sort | uniq -c | sort -nr
  1463.  
  1464. sudo tshark -i eth0 -r suspicious-time.pcap -qz io,phs
  1465.  
  1466.  
  1467.  
  1468.  
  1469. for i in session_00[0-9]*.www.html; do srcip=`cat "$i" | grep 'www:\ ' | awk '{print $2}' | cut -d ':' -f1`; dstip=`cat "$i" | grep 'www:\ ' | 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
  1470.  
  1471.  
  1472. tshark -r suspicious-time.pcap | grep 'NB.*20\>' | sed -e 's/<[^>]*>//g' | awk '{print $3,$4,$9}' | sort -u
  1473.  
  1474.  
  1475. tshark -r suspicious-time.pcap | grep 'NB.*1e\>' | sed -e 's/<[^>]*>//g' | awk '{print $3,$4,$9}' | sort -u
  1476.  
  1477.  
  1478. tshark -r suspicious-time.pcap arp | grep has | awk '{print $3," -> ",$9}' | tr -d '?'
  1479.  
  1480.  
  1481. tshark –r suspicious-time.pcap -Tfields -e “eth.src” | sort | uniq
  1482.  
  1483.  
  1484. tshark -r suspicious-time.pcap -R "browser.command==1" -Tfields -e "ip.src" -e "browser.server" | uniq
  1485.  
  1486. tshark -r suspicious-time.pcap -Tfields -e "eth.src" | sort |uniq
  1487.  
  1488. tshark -r suspicious-time.pcap -qz ip_hosts,tree
  1489.  
  1490. tshark -r suspicious-time.pcap -R "http.request" -Tfields -e "ip.src" -e "http.user_agent" | uniq
  1491.  
  1492. tshark -r suspicious-time.pcap -R "dns" -T fields -e "ip.src" -e "dns.flags.response" -e "dns.qry.name"
  1493.  
  1494.  
  1495. whois rapidshare.com.eyu32.ru
  1496.  
  1497. whois sploitme.com.cn
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503. tshark -r suspicious-time.pcap -R 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}'
  1504.  
  1505. tshark -r suspicious-time.pcap -R 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'
  1506.  
  1507. tshark -r suspicious-time.pcap -qz http_req,tree
  1508.  
  1509. tshark -r suspicious-time.pcap -R "data-text-lines contains \"<script\"" -T fields -e frame.number -e ip.src -e ip.dst
  1510.  
  1511. tshark -r suspicious-time.pcap -R 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'
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517. cd /home/malware/Desktop/Banking\ Troubles/Volatility
  1518.  
  1519. python volatility
  1520. python volatility pslist -f ../hn_forensics.vmem
  1521. python volatility connscan2 -f ../hn_forensics.vmem
  1522. python volatility memdmp -p 888 -f ../hn_forensics.vmem
  1523. python volatility memdmp -p 1752 -f ../hn_forensics.vmem
  1524. ***Takes a few min***
  1525. strings 1752.dmp | grep "^http://" | sort | uniq
  1526. strings 1752.dmp | grep "Ahttps://" | uniq -u
  1527. cd ..
  1528. cd foremost-1.5.7/
  1529. foremost -i ../Volatility/1752.dmp -t pdf -o output/pdf2
  1530. cd /home/malware/Desktop/Banking\ Troubles/foremost-1.5.7/output/pdf2/
  1531. cat audit.txt
  1532. cd pdf
  1533. ls
  1534. grep -i javascript *.pdf
  1535.  
  1536.  
  1537.  
  1538. cd /home/malware/Desktop/Banking\ Troubles/foremost-1.5.7/output/pdf5/pdf
  1539. wget http://didierstevens.com/files/software/pdf-parser_V0_6_4.zip
  1540. unzip pdf-parser_V0_6_4.zip
  1541. python pdf-parser.py -s javascript --raw 00600328.pdf
  1542. python pdf-parser.py --object 11 00600328.pdf
  1543. python pdf-parser.py --object 1054 --raw --filter 00600328.pdf > malicious.js
  1544.  
  1545. cat malicious.js
  1546.  
  1547.  
  1548. *****Sorry - no time to cover javascript de-obfuscation today*****
  1549.  
  1550.  
  1551. cd /home/malware/Desktop/Banking\ Troubles/Volatility/
  1552. python volatility files -f ../hn_forensics.vmem > files
  1553. cat files | less
  1554. python volatility malfind -f ../hn_forensics.vmem -d out
  1555. ls out/
  1556. python volatility hivescan -f ../hn_forensics.vmem
  1557. python volatility printkey -o 0xe1526748 -f ../hn_forensics.vmem Microsoft "Windows NT" CurrentVersion Winlogon
  1558. for file in $(ls *.dmp); do echo $file; strings $file | grep bankofamerica; done
Advertisement
Add Comment
Please, Sign In to add comment