Skip to content

Instantly share code, notes, and snippets.

@hahastudio
hahastudio / mandelbrot.py
Created November 19, 2012 10:29
A Mandelbrot-Shaped Python Script that generate a Mandelbrot Fractal
_ = (
255,
lambda
V ,B,c
:c and Y(V*V+B,B, c
-1)if(abs(V)<6)else
( 2+c-4*abs(V)**-0.4)/i
) ;v, x=1500,1000;C=range(v*x
);import struct;P=struct.pack;M,\
j ='<QIIHHHH',open('M.bmp','wb').write
from socket import *
import os
import struct
ADDR = ('59.78.41.61',5006)#你的IP,端口随意
BUFSIZE = 1024
filename = 'sort-collection.py'#文件名,把这个文件跟要传的文件放一个目录里
FILEINFO_SIZE=struct.calcsize('128s32sI8s')
sendSock = socket(AF_INET,SOCK_STREAM)
# -*- coding: utf-8 -*-
"""
legit.scm
~~~~~~~~~
This module provides the main interface to Git.
"""
import os
@hahastudio
hahastudio / pypcap.py
Created October 16, 2012 09:28
python pcap file analyse
from pcapy import open_offline
def filter_HTTPGET(packet):
if packet[0x33] == '\x06' and packet[0x52:0x56] == "GET ":#tcp and tcp[20:4] = 0x47455420
return True
return False
def get_source_IP(packet):
#return '.'.join(str(ord(i)) for i in packet[0x36:0x3A])
return tuple(ord(i) for i in packet[0x36:0x3A])
@hahastudio
hahastudio / dns_resolve.py
Created September 29, 2012 10:50
dns_resolve
import os
import re
import socket
import struct
def dns_resolve(host, dnsserver):
assert isinstance(host, basestring) and isinstance(dnsserver, basestring)
index = os.urandom(2)
hoststr = ''.join(chr(len(x))+x for x in host.split('.'))
data = '%s\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00%s\x00\x00\x01\x00\x01' % (index, hoststr)