Foro de elhacker.net

Programación => Scripting => Mensaje iniciado por: BigBear en 27 Agosto 2012, 00:24 am



Título: [PyQT4] Whois Online 0.2
Publicado por: BigBear en 27 Agosto 2012, 00:24 am
Queria hacer mi primer programa en PyQT4 y quise empezar con este simple cliente whois.

Una imagen de como quedo

(http://doddyhackman.webcindario.com/images/whoispy.jpg)

El codigo

Código
  1. #!usr/bin/python
  2. #Whois Online 0.2
  3. #Coded By Doddy H
  4.  
  5. import sys,urllib2,re
  6. from PyQt4 import QtCore,QtGui
  7.  
  8. nave = urllib2.build_opener()
  9. nave.add_header = [('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5')]
  10.  
  11. def tomar(web,vars) :
  12. return nave.open(web,vars).read()
  13.  
  14. def whois(domain):
  15. try:
  16.  code = tomar("http://networking.ringofsaturn.com/Tools/whois.php","domain="+domain+"&"+"submit=submit")
  17.  if (re.findall("<PRE>(.*?)<\/PRE>",code,re.S)):
  18.   found = re.findall("<PRE>(.*?)<\/PRE>",code,re.S)
  19.   resul = found[0]
  20.   resul = re.sub("&quot;","",resul)
  21.   resul = re.sub("&gt;&gt;&gt;","",resul)
  22.   resul = re.sub("&lt;&lt;&lt;","",resul)
  23.   return resul
  24.  else:
  25.   return "Not Found"
  26. except:
  27.  print "[-] Page offline\n"
  28.  
  29. def comando():
  30.  
  31. new.console.clear()
  32. new.console.appendPlainText(whois(str(new.dom.text())))
  33.  
  34. app = QtGui.QApplication(sys.argv)
  35.  
  36. new = QtGui.QWidget()
  37.  
  38. new.setWindowTitle("Whois Online 0.2 || Coded By Doddy H")
  39. new.resize(450,420)
  40. new.setStyleSheet("QWidget {background-color: #000000;color: #00FF00}")
  41.  
  42. new.label1 = QtGui.QLabel("Domain : ",new)
  43. new.label1.setStyleSheet("QWidget {background-color: #000000;color: #00FF00;font: normal 17px Verdana}")
  44. new.label1.setGeometry(20,23,80,20)
  45.  
  46. new.dom = QtGui.QLineEdit(new)
  47. new.dom.setStyleSheet("QWidget {background-color: #000000; color: #00FF00;border: 2px solid #00FF00}")
  48. new.dom.setGeometry(95,23,200,25)
  49.  
  50. new.search = QtGui.QPushButton("Search",new)
  51. new.search.setGeometry(310,22,110,28)
  52. new.search.setStyleSheet("QWidget {background-color: #000000; color: #00FF00;border: 2px solid #00FF00}")
  53.  
  54. new.label2 = QtGui.QLabel("Console",new)
  55. new.label2.setStyleSheet("QWidget {background-color: #000000;color: #00FF00;font: normal 17px Verdana}")
  56. new.label2.setGeometry(200,70,70,20)
  57.  
  58. new.console = QtGui.QPlainTextEdit(new)
  59. new.console.setGeometry(50,100,350,300)
  60. new.console.setStyleSheet("QWidget {background-color: #000000; color: #00FF00;border: 2px solid #00FF00}")
  61.  
  62. new.connect(new.search,QtCore.SIGNAL("clicked()"),comando)
  63.  
  64. new.show()
  65.  
  66. sys.exit(app.exec_())
  67.  
  68. # The End ?
  69.