Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: [Send raw] Send on a port by IP
PostPosted: 09 Feb 2014, 16:29 
Membre

Joined: 15 Jul 2009, 15:10
Posts: 3
Voila un outil que j'ai développé il y a quelque temps, permet d'envoyer un fichier brut sur un port donné sur une cible. Les données sont récupérables avec netcat ou n'importe quel programme d'écoute sur port.

#!/usr/bin/env python
# encoding: UTF-8
#Prod by Bacterie

import sys
import os
from os import system
from os import path
import subprocess
from subprocess import call
import datetime
import shutil
import string
import socket
import pygtk
pygtk.require('2.0')
import gtk
import time


################################################################################


class windows(object):

def delete_event(self, widget, event, data=None):
print "Demande de fermeture."
return False

def destroy(self, widget, data=None):
print "Fermeture ......"
gtk.main_quit()

def hide(self, window):
window.hide()

def __init__(self):

###### FENETRE ######

window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_border_width(30)
window.set_resizable(False)
window.connect("destroy", self.destroy)
window.connect("delete_event", self.delete_event)
window.set_title("IP send ~ by Bacterie")

###### BOXES & BOUTTONS ######

vbox=gtk.VBox()
hbox2=gtk.HBox()
hbox=gtk.HBox()

host = gtk.Entry()
host.set_max_length(15)
host.set_size_request(175, 25)
host.set_text("IP")
host.set_editable(True)
host.show()
hbox.pack_start(host)

adjustment = gtk.Adjustment(1024.0, 1.0, 99999.0, 1.0, 1.0, 1.0)
self.spin = gtk.SpinButton(adjustment=None, climb_rate=1.0, digits=0)
self.spin.set_adjustment(adjustment)
adjustment = self.spin.get_adjustment()
#port.set_max_length(5)
#port.set_size_request(75, 25)
#port.set_text("Port")
#port.set_editable(True)
#port.show()
hbox.pack_start(self.spin)
self.spin.show()

self.file1 = gtk.Entry()
self.file1.set_text("Fichier")
self.file1.set_size_request(25, 25)
self.file1.set_editable(False)
self.file1.show()
hbox2.pack_start(self.file1)

fichier = gtk.Button("Parcourir...")
fichier.connect("clicked", self.seek, None)
fichier.set_size_request(25, 25)
fichier.show()
hbox2.pack_start(fichier)

send=gtk.Button("Envoyer")
send.connect("clicked", self.envoi, host)
send.set_size_request(30, 30)
send.show()
hbox2.pack_start(send)

vbox.pack_start(hbox)
vbox.pack_start(hbox2)

window.add(vbox)
vbox.show()
hbox.show()
hbox2.show()
window.show()


def seek(self, widget, data=None):
find = gtk.FileChooserDialog("Fichier alarme...", None, gtk.FILE_CHOOSER_ACTION_OPEN, ((gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)))
self.result = find.run()
self.resultat = find.get_filename()
find.destroy()
self.file1.set_text(str(self.resultat))

#if resultat == gtk.RESPONSE_OK:
#ouvrirFichier(None, self.file1, find.set_select_multiple(False))

#def ouvrirFichier(self, widget, resultat):


def envoi(self, widget, host):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host = host.get_text()
port = self.spin.get_value_as_int()
print port
sock.connect((host, port))
alarm = open(self.resultat, "r")
self.lecture = alarm.readlines()
for line in self.lecture:
sock.sendall(str(line))
time.sleep(0.05)
sock.close()
alarm.close()

def main(self):
gtk.main()


################################################################################

### Création et affichage final. ###

if __name__ == "__main__":
Bienvenue = windows()
Bienvenue.main()

################################################################################
# End of file
################################################################################

Je m'étais amusé a faire une interface graphique aussi :P

Amicalement ^^


Top
 Profile  
 
Post new topic Reply to topic  [ 1 post ] 


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group