Jump to content

Phrack - great old school hacking e-zine


killab
 Share

Recommended Posts

Well since we're talking about phrack link I'll add a little script I wrote years back to back up phrack files. you can tell its age because at the time i wrote it we were only up to issue 67.

#!/usr/bin/env python

import sys
import socket


def recvline(sock):
    stop = 0
    line = ''
    while True:
        i = sock.recv(1)
        if i == '\n': stop = 1
        line += i
        if stop == 1:
            break
    return line

# super awesome recvall function!
def recvall(sock, size):
    buff = ''
    while True:
        buff += sock.recv(size)
        if len(buff) < size:
            size -= len(buff)
            continue
        else:
            return buff

def getheader(s):
    header = []
    for n in range(9):
        header.append(recvline(s))
    return header


def main():
    host = socket.gethostbyname('www.phrack.org')
    port = 80
    for issue in xrange(0,67): # modify for issue ranges
        print "Getting issue {0} of 67".format(issue+1),
        s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
        s.connect((host,port))
        # if statement for the naming
        s.sendall('GET /archives/tgz/phrack{0}.tar.gz HTTP/1.1\r\n'
                    .format(issue+1))
        s.sendall('Host: www.phrack.org\r\n\r\n')

        header = getheader(s)
        load = int(header[6].split(':')[1].rstrip())
        print "size: " + str(load) + " bytes"
        # another if statement for naming
        f = open('phrack{0}.tar.gz'.format(issue+1),'wb')

        while True:
            recv_size = 100
            if load < recv_size:
                f.write(recvall(s, load))
                break
            else:
                f.write(recvall(s, recv_size))
            load -= recv_size

        f.close()
        s.close()
    return 0

if __name__ == '__main__':
    main()

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Similar Content

    • killab
      By killab
      Badass mind map for passive open source intelligence gathering.
      http://osintframework.com/
       
    • killab
      By killab
      ExploitDB, Offensive Security's Exploit Database Archive is an amazing resource.
      Be it for google dorks, exploits, shellcode, or technical papers.
      https://www.exploit-db.com/
      Want to be able to search for exploits offline, or via terminal?
      Check out the following, a few simple commands will arm you with the entire DB!
      https://www.exploit-db.com/searchsploit/
    • killab
      By killab
      Many of you will no doubt already have this site bookmarked but it is worth a mention even if one person does not.
      This site contains a ton of recent news on topics like how apple has fucked up yet again, or what malware is now sweeping the globe.
      Along with that, they also have many exploits, and informative whitepapers.
       
      https://packetstormsecurity.com/
×
×
  • Create New...