Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ColonelPanic

Pages: [1] 2
1
Hardware / Re: Miniature file/backup server at home?
« on: June 29, 2015, 07:30:47 pm »
My buddy put Arch on a PogoPlug (http://www.amazon.com/Pogoplug-Series-4-Backup-Device/dp/B006I5MKZY) and uses it as a seedbox/home media server and seems happy with it. He did something like this, IIRC: http://blog.qnology.com/2013/03/tutorial-pogoplug-e02-with-arch-linux.html

2
Scripting Languages / Reversing a hash
« on: June 29, 2015, 04:58:37 am »
Hey all,
I'm working on this problem to reverse a hash. I've got a solution, but I think it's a bit of a hack and I'd like to see what I'm missing. This is a (broken) hash function that accepts a 16-byte input (16 integers in range(256)). A value of zero is assumed for hash[0] (message[-1] = 0).

Hash function is:
Code: [Select]
     hash[i] = ((129 * message[i]) XOR message[i-1]) % 256



Code: [Select]
def hashme(message):
    return [(((129 * m) ^ (0 if i is 0 else message[i-1]))%256) for (i, m) in enumerate(message)]


def _gcd(a,b):
    while b:
        a, b = b, a % b
    return abs(a)


def unhashme(digest):
    msg = [0] * len(digest)
    lastbyte = 0
    for (i, ch) in enumerate(digest):
        newchar = (ch ^ (lastbyte * 129))
        if _gcd(ch, 256) is 1:
            newbyte += 128
        newbyte = newbyte % 256
        msg[i] = newbyte
        lastbyte = newbyte
    return msg
The above 'unhashme' function works, but it feels inelegant. When run without the GCD calculation (and thus not offsetting the value by m/2 = 128), every other element seems to reverse correctly, but the others are off by 128. Multiplying by 19 will reverse the multiplication by 129 (modulo 256), but I'm not sure how/where to work it in. I feel like adding 128 here-and-there is hacky, or at best, missing the underlying intent. I'm going in circles between rings, cyclic groups, multiplicitive inverses, etc.


Can anyone explain what I'm missing, or give me a direction to search?




Input:    0,129,5,141,25,137,61,149,113,145,53,157,233,185,109,165
-------------------------------------------------------------------
No GCD:   0,129,4,137,16,153,36,177,64,209,100,249,144,41,196,97
-------------------------------------------------------------------
Expected: 0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225


Test data:
test1_input = [0, 129, 3, 129, 7, 129, 3, 129, 15, 129, 3, 129, 7, 129, 3, 129]
test1_output = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]


test2_input = [0, 129, 5, 141, 25, 137, 61, 149, 113, 145, 53, 157, 233, 185, 109, 165]
test2_output = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]

3
Hacking and Security / Re: 1 day of running a SSH honeypot
« on: June 24, 2015, 12:15:43 am »
This is rampant on hosted boxes (Hetzner, DigitalOcean, etc.) since they use known blocks of IP addresses. If I had to guess, I'd say the reason is either 1) skids playing with tools on default settings (or checking all the boxes), or 2) people targeting the one-click install images available on sites like DigitalOcean. e.g., hoping someone spun up a GitLab instance and forgot about it, or only used the web installer. With images like WordPress and such available, I'm sure it's pretty common.

4
Session hijacking is possible anytime you can intercept, predict or otherwise acquire the session ID. So, if someone is using really awful session IDs that you can predict, you can certainly do it over HTTPS. Additionally, there's the "Secure" flag on cookies. If it's not set, the data will be visible over HTTP. Even if it is set, you can overwrite it with a plaintext cookie.

5
Have you tried not stalking people?

6
Tamper data?

For web pentesting Burpsuite is hands down the best IMO.


Yeah, that's it! And I was thinking about Burpsuite at work today. Wireshark is supposedly useful, but frankly I've yet to wrap my head around it. I've used it in some super-specific situations, but otherwise haven't used it much.

7
You generally don't need a lot of fancy tools, especially if you can write Python (or bash scripts with curl or something). There are some REST API clients available as browser extensions and standalone programs, which are useful for crafting requests.A cookie editor is sometimes useful as well. There was also a cool Firefox extension I used a while ago that intercepted requests and let you edit request data, but I forget the name. Otherwise, I typically use a Python script for repetitive/sequential tasks. The "requests" module, BeautifulSoup and Scrapy are all useful to that end.

8
Networking / Re: [question] Setting up a small village ISP
« on: June 13, 2015, 07:41:06 pm »

This sounds like a good place for mesh networking. It can be done with new/used routers and a base internet connection. A lot of vendors sell ready-made devices (Cisco, Ruckus SmartMesh, VillageTelco, etc.) I flashed some WR54G routers from Goodwill and had a small setup going, but never tried to scale it.

There was a pretty good whitepaper/case study about using them in small villages in Africa or something, but I'm coming up short today.


9
In the interest of specificity, Wikipedia cites the image as
Quote
"Software" engineer Margaret Hamilton with a pile of print-out results from simulations, circa 1969. (MIT Library)
.

As an aside, the footnote reads ""Apollo 11 Owners' Workshop Manual" (Haynes) p105". Apparently, this is a thing: http://www.haynes.co.uk/webapp/wcs/stores/servlet/BookFeature_Apollo11View?storeId=10001&catalogId=10001


10
Beginner's Corner / Re: Knowledge required for web programmer
« on: June 06, 2015, 12:49:16 am »
Haven't use PDO myself. But afaik when with mysqli(-driver) you can communicate only with mysql databases, but with right PDO-driver you can use mysql, microsoft sql, postgresql, sqlite, etc. databases. So i think pdo's flexibility is one of it advantages. Correct me if i'm wrong.


This is correct; the mysqli_* functions were kinda a fix for the mysql_* ones. The mysqli_* set allows you to easily update the mysql_* functions and maintain a functional programming style (vs OOP). PDO's, to my knowledge, must be an object, whereas mysqli provides a functional AND OOP interface.


That being said, PDO is the standard, particularly among open-source projects. This is largely to allow the interchangeability between databases, as mentioned, as well as the OOP style. Either is preferred over mysql_*, but they're approximately equivalent for all intents and purposes.

11
Beginner's Corner / Re: [Python]My first program
« on: May 30, 2015, 04:10:58 pm »

While it doesn't do much, it looks like you've gotten some momentum in learning Python. Since you posted what you've tried, here's essentially the same program, but organized a little differently. Some notes:
  • Inclusion of shebang line
  • Moved imports to the top, where they generally belong
  • Menu is a little more dynamic (see how much easier it is to add an option here)
  • Moved functions into actual functions. (Google "DRY code")
  • Removed regex. Although your solution certainly works (and congrats on tackling regex this early), I'll let you research why I chose to do that. (Hint: https://xkcd.com/1171/)
Now, some homework, if you choose to accept it:
  • I want to run this program from the command line, like so "python crack.py <ip_address> <target_OS>". Use the sys module (or optparse/argparse) to make it happen.
  • Detect the operating system via platform module. Since this would only work on the local machine, see if you can open a socket to the requested IP and grab the banners.
  • Despite randomly choosing a vulnerability, this program will always give the same output. WHY?
  • In terms of reusing code, what's the advantage of the "if __name__ == '__main__'" block?
Code: [Select]
#!/usr/bin/env python
"""
PyCracker by Khofo


<Disclaimer here>
"""
import os, random


CLS='clear' # change to 'cls' for Windows, or use os.platform


def check_ip(ip):
    parts = [int(x) for x in ip.split('.')]
    if len(parts) == 4:
        if max(parts) <= 255 and min(parts) > 0:
            return True
    return False


def get_os():
    supported = ["Windows", "Linux", "OSX"]
    opt = None
    error = None
    while opt is None:
        os.system(CLS)
        if error:
            print error
        print(" Please define target computer's OS")
        for (i,opsys) in enumerate(supported):
            print(" %d) %s" % (i, opsys))
        print(" q) Quit")
       
        choice = raw_input(": ")
        if choice is 'q':
            quit()
        try:
            choice = int(choice)
            if choice not in range(1,5):
                error = "Invalid choice"
                continue
            opt = supported[choice]
        except (ValueError, IndexError):
            error = "Invalid choice"
    return opt


def check_vulns(ip):
    """A bogus function to check for vulns."""
    known_vulns = [
        None, None, None,
        'vuln A', None, 'vuln B',
        None, 'vuln C', None, 'vuln D'
        ]
    seed = 1
    random.seed(seed)
    return known_vulns[random.randint(0, len(known_vulns))]


def exploit_vulns(vuln):
    print("Exploiting %s" % vuln)
    return False


def scan_target(ip, opsys=None):
    opsys = opsys if opsys else "Unknown"
    print("Scanning target %s (OS: %s)" % (ip, opsys))
    vuln = check_vulns(ip)
    if vuln:
        print(" Found vulnerablity: %s" % vuln)
        if exploit_vulns(vuln):
            print(" Exploit successful!")
        else:
            print(" Exploit failed!")
    else:
        print("No vulnerabilities found!")


       
def main():
    opsys = get_os()
    valid_ip = None
    while valid_ip is None:
        ip = raw_input("Target IP: ")
        if not check_ip(ip):
            print("Invalid IP address")
            continue
        valid_ip = ip
    scan_target(ip, opsys)
    print("kthanxbai")


if __name__ == "__main__":
    main()

Finally, a SSCCE for the random problem:

Code: [Select]

import random
random.seed(1)
for i in range(100):
    print random.randint(1, 100)


Edit:
Some references (also submitted to eBooks section):
ViolentPython.pdf (Start here)

GrayHatPython.pdf


12
Beginner's Corner / Re: Starting programming?
« on: May 30, 2015, 05:23:35 am »
1) Stop being lazy.
2) Write code.
3) Write more code.
4) Go back and look at the awful code you wrote in step 2. Unfuck it. Make it faster. Make it use less memory. Make it more secure. If it's a script, make it OOP. If it's OOP, try to make it procedural.
5) Repeat.


If you're stuck on the bullshit tutorials, pick something you're interested in and write a program that involves that subject. Make a system to catalog your music/movie/porn collection. Write a browser plugin that downloads YouTube videos, whatever. If you find yourself doing the same repetitive task, figure out how to automate it. It doesn't really matter what you write, just write code.


As a corollary to that last statement, try googling "best way to <do something> in <language>". Look at the options, and don't settle for the first half-assed answer you see. While that's fine for prototyping or getting your feet wet, there are often lots of problems with the basic examples. Find a faster, better, more secure way of doing it. Then, test that shit and find what breaks, and fix it. Supply invalid input. Break things, fix them, then learn how to prevent them from breaking again.


The answers are out there - you may have to search for specific answers, but you can pretty much write any program in any language by searching StackOverflow and the likes. Just google it.


"how to save to a file in <language>"
"how to parse HTML in <language>"
etc.




Learning a computer language is just like learning any other language. You can sit in class, read about it, and wish you were fluent all day long, but until you get out there and start using it, you'll never know shit.


13
Web Oriented Coding / Re: [MySQL] How to view 'ibdata1' file
« on: May 24, 2015, 11:38:00 pm »
Have you tried using mysql?

14
General discussion / Re: Where do you get malware samples to study?
« on: May 14, 2015, 01:28:13 pm »
I've been wondering this myself lately. Thanks man!

15
Tutorials / Re: Stealing User Info with PHP Images
« on: May 14, 2015, 01:08:49 pm »
Here's an example that works with .htaccess to generate images a couple different ways. (All of them are basically using the output of file_get_contents). It's designed to be "index.php" in, say, your /images/ directory. URL's can be "site.com/images/whatever.jpg", and you can generate the image like the original, read it from disk, DB, etc.
Please don't use a database to store images in real life.

Code: (php) [Select]
<?php
// Log the json-encoded SERVER array for later parsing. This can also be had from access.log
error_log(json_encode($_SERVER));


if (isset(
$_GET['f'])) {
    
/* prevent path traversal */
    
$f basename($_GET['f']);
    
/**
     * Determine the picture by UserAgent
     */
    
$image '';
    if (
$f == 'useragent.png') {
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'linux')) {
    $image 'linux.png';
} elseif (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows')) {
    $image 'windows.png';
} elseif (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'osx')) {
    $image 'osx.png';
}
/*
 * You could then continue with the image manipulation functions
 * to output text. e.g., timestamps, 'your IP is..' images, etc.
 */
/**
 * Just read out the file
 */
if ($image && file_exists($image)) {
    header('COntent-Type: image/png');
    die(file_get_contents($image));
}
    }
    
/** 
     * An example of aliasing an image to another site.
     * The IP of your server will be visible in evilzone's logs
     * each time someone views this page.
     */
    
if ($f == 'hacking.jpg' || $f 'hacking.foo') {
header('Content-Type: image/png');
die(file_get_contents('https://evilzone.org/logo_02.png'));
    }
    
/**
     * You'll obviously need a database with info for this to work.
     */
    
if ($f == 'database.png') {
$stmt $pdo->prepare('SELECT image_data, content_type FROM images WHERE image_name = :name');
$stmt->execute(array('name' => $f));
$row $stmt->fetch();
header('Content-Type: ' $row['content_type']);
die($row['image_data']);
    }
    
/** 
     * Get from local filesystem
     * 1) Don't trust user's file extension for Content-Type and do some
     *    long switch/case. Just read it from the source file.
     */
    
if ($f && file_exists($f)) {
$contentType exif_imagetype($f);
header("Content-Type: {$contentType}");
die(file_get_contents($f));
    }
}


/** 
 * Make it look like native 404 page
 */
header('HTTP/1.0 404 - Not Found');
$url htmlentities($_SERVER['REQUEST_URI']);
$html=<<<EOF
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL 
{$url} was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at 
{$SERVER['SERVER_NAME']} Port {$_SERVER['SERVER_PORT']}</address>
</body></html>
EOF;
die(
$html);


And the .htaccess rewrite rule:

Code: [Select]
RewriteEngine On
# Redirect /<file>.<ext> to index.php?f=<file>.<ext> [NoCasesensitive, Last]
RewriteRule ([^\.]+)\.(png|jpg|gif)$ index.php?f=$1.$2 [NC,L]

Pages: [1] 2