Waraxe IT Security Portal
Login or Register
December 22, 2024
Menu
Home
Logout
Discussions
Forums
Members List
IRC chat
Tools
Base64 coder
MD5 hash
CRC32 checksum
ROT13 coder
SHA-1 hash
URL-decoder
Sql Char Encoder
Affiliates
y3dips ITsec
Md5 Cracker
User Manuals
AlbumNow
Content
Content
Sections
FAQ
Top
Info
Feedback
Recommend Us
Search
Journal
Your Account
User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144

People Online:
Visitors: 182
Members: 0
Total: 182
Full disclosure
CyberDanube Security Research 20241219-0 | Authenticated Remote Code Execution in Ewon Flexy 205
Stored XSS with Filter Bypass - blogenginev3.3.8
[SYSS-2024-085]: Broadcom CA Client Automation - Improper Privilege Management (CWE-269)
[KIS-2024-07] GFI Kerio Control <= 9.4.5 Multiple HTTP Response Splitting Vulnerabilities
RansomLordNG - anti-ransomware exploit tool
APPLE-SA-12-11-2024-9 Safari 18.2
APPLE-SA-12-11-2024-8 visionOS 2.2
APPLE-SA-12-11-2024-7 tvOS 18.2
APPLE-SA-12-11-2024-6 watchOS 11.2
APPLE-SA-12-11-2024-5 macOS Ventura 13.7.2
APPLE-SA-12-11-2024-4 macOS Sonoma 14.7.2
APPLE-SA-12-11-2024-3 macOS Sequoia 15.2
APPLE-SA-12-11-2024-2 iPadOS 17.7.3
APPLE-SA-12-11-2024-1 iOS 18.2 and iPadOS 18.2
SEC Consult SA-20241211-0 :: Reflected Cross-Site Scripting in Numerix License Server Administration System Login
Log in Register Forum FAQ Memberlist Search
IT Security and Insecurity Portal

www.waraxe.us Forum Index -> Remote file inclusion -> Possible Rfi? Shed Some light Please!
Post new topicReply to topic View previous topic :: View next topic
Possible Rfi? Shed Some light Please!
PostPosted: Thu Oct 09, 2008 4:25 pm Reply with quote
Cablekid
Advanced user
Advanced user
Joined: Jul 14, 2007
Posts: 85




Help me out.


Alright, i have a website that lets you upload image files.

I found out if you do http://site.com/insert_image.php?dir=..%2F..

It shows you the directory and it also lets you upload an image to that directory.

So my question is, is their any other way to maybe use a shell? I was thinking about uploading a shell but in the config.php it defines only jpgs and gifs

Code:
require('config.inc.php');
error_reporting(0);
// get the identifier of the editor
$wysiwyg = $_GET['wysiwyg'];
// set image dir
$leadon = $rootdir.$imagebasedir;

if($leadon=='.') $leadon = '';
if((substr($leadon, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/';
$startdir = $leadon;

// validate the directory
$_GET['dir'] = $_POST['dir'] ? $_POST['dir'] : $_GET['dir'];
if($_GET['dir']) {
if(substr($_GET['dir'], -1, 1)!='/') {
$_GET['dir'] = $_GET['dir'] . '/';
}
$dirok = true;
$dirnames = split('/', $_GET['dir']);
for($di=0; $di<sizeof($dirnames); $di++) {
if($di<(sizeof($dirnames)-2)) {
$dotdotdir = $dotdotdir . $dirnames[$di] . '/';
}
}
if(substr($_GET['dir'], 0, 1)=='/') {
$dirok = false;
}

if($_GET['dir'] == $leadon) {
$dirok = false;
}

if($dirok) {
$leadon = $_GET['dir'];
}
}

// upload file
if($allowuploads && $_FILES['file']) {
$upload = true;
if(!$overwrite) {
if(file_exists($leadon.$_FILES['file']['name'])) {
$upload = false;
}
}
$ext = strtolower(substr($_FILES['file']['name'], strrpos($_FILES['file']['name'], '.')+1));
if(!in_array($ext, $supportedextentions)) {
$upload = false;
}
if($upload) {
move_uploaded_file($_FILES['file']['tmp_name'], $leadon . $_FILES['file']['name']);
}
}

if($allowuploads) {
$phpallowuploads = (bool) ini_get('file_uploads');
$phpmaxsize = ini_get('upload_max_filesize');
$phpmaxsize = trim($phpmaxsize);
$last = strtolower($phpmaxsize{strlen($phpmaxsize)-1});
switch($last) {
case 'g':
$phpmaxsize *= 1024;
case 'm':
$phpmaxsize *= 1024;
}
}

?>
[/u]
View user's profile Send private message
PostPosted: Thu Oct 09, 2008 4:37 pm Reply with quote
lenny
Valuable expert
Valuable expert
Joined: May 15, 2008
Posts: 275




Do you have the entire source code? You could try to upload a php file with the image/jpeg content type - that method has worked for me several times, only problem being if the code checks file extensions from the uploaded files...
View user's profile Send private message
PostPosted: Thu Oct 09, 2008 4:46 pm Reply with quote
Cablekid
Advanced user
Advanced user
Joined: Jul 14, 2007
Posts: 85




How dose 1 do that?

Here is the entire source.

Config.inc.php


Code:
<?php
*
* Path to a directory which holds the images.
*/
$imagebasedir = '../../uploads';

/*
* An absolute or relative URL to the image folder.
* This url is used to generate the source of the image.
*/
$imagebaseurl = 'uploads';

/*
* Allow your users to browse the subdir of the defined basedir.
*/
$browsedirs = true;

/*
* If enabled users will be able to upload
* files to any viewable directory. You should really only enable
* this if the area this script is in is already password protected.
*/
$allowuploads = true;

/*
* If a user uploads a file with the same
* name as an existing file do you want the existing file
* to be overwritten?
*/
$overwrite = false;

/*
* Define the extentions you want to show within the
* directory listing. The extensions also limit the
* files the user can upload to your image folders.
*/
$supportedextentions = array(
'gif',
'png',
'jpeg',
'jpg',
'bmp'
);

/*
* If you want to add your own special file icons use
* this section below. Each entry relates to the extension of the
* given file, in the form <extension> => <filename>.
* These files must be located within the dlf directory.
*/
$filetypes = array (
'png' => 'jpg.gif',
'jpeg' => 'jpg.gif',
'bmp' => 'jpg.gif',
'jpg' => 'jpg.gif',
'gif' => 'gif.gif',
'psd' => 'psd.gif',
);

?>


insert_image.php

Code:
<?php
require('config.inc.php');
error_reporting(0);
// get the identifier of the editor
$wysiwyg = $_GET['wysiwyg'];
// set image dir
$leadon = $rootdir.$imagebasedir;

if($leadon=='.') $leadon = '';
if((substr($leadon, -1, 1)!='/') && $leadon!='') $leadon = $leadon . '/';
$startdir = $leadon;

// validate the directory
$_GET['dir'] = $_POST['dir'] ? $_POST['dir'] : $_GET['dir'];
if($_GET['dir']) {
if(substr($_GET['dir'], -1, 1)!='/') {
$_GET['dir'] = $_GET['dir'] . '/';
}
$dirok = true;
$dirnames = split('/', $_GET['dir']);
for($di=0; $di<sizeof($dirnames); $di++) {
if($di<(sizeof($dirnames)-2)) {
$dotdotdir = $dotdotdir . $dirnames[$di] . '/';
}
}
if(substr($_GET['dir'], 0, 1)=='/') {
$dirok = false;
}

if($_GET['dir'] == $leadon) {
$dirok = false;
}

if($dirok) {
$leadon = $_GET['dir'];
}
}

// upload file
if($allowuploads && $_FILES['file']) {
$upload = true;
if(!$overwrite) {
if(file_exists($leadon.$_FILES['file']['name'])) {
$upload = false;
}
}
$ext = strtolower(substr($_FILES['file']['name'], strrpos($_FILES['file']['name'], '.')+1));
if(!in_array($ext, $supportedextentions)) {
$upload = false;
}
if($upload) {
move_uploaded_file($_FILES['file']['tmp_name'], $leadon . $_FILES['file']['name']);
}
}

if($allowuploads) {
$phpallowuploads = (bool) ini_get('file_uploads');
$phpmaxsize = ini_get('upload_max_filesize');
$phpmaxsize = trim($phpmaxsize);
$last = strtolower($phpmaxsize{strlen($phpmaxsize)-1});
switch($last) {
case 'g':
$phpmaxsize *= 1024;
case 'm':
$phpmaxsize *= 1024;
}
}

?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
</head>
<table width="200" border="0" cellpadding="0" cellspacing="0" style="background-color: #F7F7F7; border: 2px solid #FFFFFF; padding: 5px;">
<tr>
<td style="width: 115px;padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;" width="100">Alignment:</td>
<td style="width: 85px;padding-bottom: 2px; padding-top: 0px;">
<select name="align" id="align" style="font-family: arial, verdana, helvetica; font-size: 11px; width: 100%;">
<option value="">Not Set</option>
<option value="left">Left</option>
<option value="right">Right</option>
<option value="texttop">Texttop</option>
<option value="absmiddle">Absmiddle</option>
<option value="baseline">Baseline</option>
<option value="absbottom">Absbottom</option>
<option value="bottom">Bottom</option>
<option value="middle">Middle</option>
<option value="top">Top</option>
</select>
</td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Horizontal Space:</td>
<td style="padding-bottom: 2px; padding-top: 0px;"><input type="text" name="hspace" id="hspace" value="" style="font-size: 10px; width: 100%;"></td>
</tr>
<tr>
<td style="padding-bottom: 2px; padding-top: 0px; font-family: arial, verdana, helvetica; font-size: 11px;">Vertical Space:</td>
<td style="padding-bottom: 2px; padding-top: 0px;"><input type="text" name="vspace" id="vspace" value="" style="font-size: 10px; width: 100%;"></td>
</tr>
</table>

</td>
</tr>
</table>
</td>
<td style="vertical-align: top;width: 150px; padding-left: 5px;">
<span style="font-family: arial, verdana, helvetica; font-size: 11px; font-weight: bold;">Select Image:</span>
<iframe id="chooser" frameborder="0" style="height:165px;width: 180px;border: 2px solid #FFFFFF; padding: 5px;" src="select_image.php?dir=<?php echo $leadon; ?>"></iframe>
</td>
</tr>
<tr>
<td colspan="2" align="right" style="padding-top: 5px;">
<input type="submit" value=" Submit " onclick="insertImage();return false;" style="font-size: 12px;">
<?php if ( $allowuploads ) { ?>
<input type="submit" value=" Upload " style="font-size: 12px;">
<?php } ?>
<input type="button" value=" Cancel " onclick="window.close();" style="font-size: 12px;">
</td>
</tr>
</form>
</table>
</body>
</html>
View user's profile Send private message
PostPosted: Thu Oct 09, 2008 6:08 pm Reply with quote
pexli
Valuable expert
Valuable expert
Joined: May 24, 2007
Posts: 665
Location: Bulgaria




.php.jpg
View user's profile Send private message
PostPosted: Thu Oct 09, 2008 6:49 pm Reply with quote
Cablekid
Advanced user
Advanced user
Joined: Jul 14, 2007
Posts: 85




YES U ROCK I DID MY VERY FIRST EXPLOIT! AWSOME! MY OWN!

SWEET!
View user's profile Send private message
PostPosted: Thu Oct 09, 2008 7:32 pm Reply with quote
pexli
Valuable expert
Valuable expert
Joined: May 24, 2007
Posts: 665
Location: Bulgaria




Congrats:)
View user's profile Send private message
PostPosted: Thu Oct 09, 2008 8:25 pm Reply with quote
Cablekid
Advanced user
Advanced user
Joined: Jul 14, 2007
Posts: 85




How dose one go about submitting this to milw0rm.

do you send an email.
View user's profile Send private message
PostPosted: Fri Oct 10, 2008 6:34 am Reply with quote
pexli
Valuable expert
Valuable expert
Joined: May 24, 2007
Posts: 665
Location: Bulgaria




before you submit something on milw0rm you need to investigate why this hole working here but not working there.Google help's you.
View user's profile Send private message
PostPosted: Fri Oct 10, 2008 5:13 pm Reply with quote
Cablekid
Advanced user
Advanced user
Joined: Jul 14, 2007
Posts: 85




Alright,

Question for ya..

When i upload the shell on some sites, it says

Code:
Forbidden
You don't have permission to access /graph/tmp/home1.php.jpg on this server.


When i go to it, Is that because the server doesn't chmod it to be readable.

If so any other way you can upload shells?
View user's profile Send private message
PostPosted: Fri Oct 10, 2008 5:18 pm Reply with quote
pexli
Valuable expert
Valuable expert
Joined: May 24, 2007
Posts: 665
Location: Bulgaria




Cablekid wrote:
Alright,

Question for ya..

When i upload the shell on some sites, it says

Code:
Forbidden
You don't have permission to access /graph/tmp/home1.php.jpg on this server.


When i go to it, Is that because the server doesn't chmod it to be readable.

If so any other way you can upload shells?


Yep.This depend of server settings.If you try like this

/graph/tmp/home1.php
View user's profile Send private message
PostPosted: Fri Oct 10, 2008 6:42 pm Reply with quote
Cablekid
Advanced user
Advanced user
Joined: Jul 14, 2007
Posts: 85




Ya i tried like this
/graph/tmp/home1.php
and like this /graph/tmp/home1.php.jpg

same thing, so its not possible to upload php to this site?
View user's profile Send private message
PostPosted: Fri Oct 10, 2008 9:08 pm Reply with quote
pexli
Valuable expert
Valuable expert
Joined: May 24, 2007
Posts: 665
Location: Bulgaria




Try to upload .htaccess with

AddType application/x-httpd-php .php

try .htaccess%00
View user's profile Send private message
PostPosted: Fri Oct 10, 2008 10:51 pm Reply with quote
Cablekid
Advanced user
Advanced user
Joined: Jul 14, 2007
Posts: 85




Smart idea, i tried it still didn't work.
View user's profile Send private message
Possible Rfi? Shed Some light Please!
www.waraxe.us Forum Index -> Remote file inclusion
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT
Page 1 of 1

Post new topicReply to topic


Powered by phpBB © 2001-2008 phpBB Group



Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2024 Janek Vind "waraxe"
Page Generation: 0.043 Seconds