Tekil Mesaj gösterimi
Alt 06-09-2008   #1
Profil
Üye
 
Kerem388 - ait Kullanıcı Resmi (Avatar)
 
Üyelik tarihi: Dec 2007
Bulunduğu yer: oras hakında çesitli söylentiler var karar veremedik
Yaş: 37
Mesajlar: 938
Üye No: 10499

Seviye: 27 [♥ Bé-Yêu ♥♥ Bé-Yêu ♥♥ Bé-Yêu ♥]
Canlılık: 0 / 656
Çekicilik: 312 / 33197
Tecrübe: 25

Teşekkür

Teşekkürler: 0
0 Mesajina 0 Tesekkür Aldi
Rep
Rep Puanı : 1047
Rep Gücü : 28
İtibar :
Kerem388 has much to be proud ofKerem388 has much to be proud ofKerem388 has much to be proud ofKerem388 has much to be proud ofKerem388 has much to be proud ofKerem388 has much to be proud ofKerem388 has much to be proud of
97 Python ile Port Tarama

Tanımlanan IP Adresine Göre Port Tarama Yapan Bir Script.

Click the image to open in full size.

KOD :
-------------------------------------------------

# -*- coding:cp1254 -*-
#!/usr/bin/python

import socket as sk
import socket
import sys
import threading, Queue
import os

MAX_THREADS = 50

class Scanner(threading.Thread):
def __init__(self, inq, outq):
threading.Thread.__init__(self)
self.setDaemon(1)
# queues for (host, port)
self.inq = inq
self.outq = outq

def run(self):
while 1:
host, port = self.inq.get()
sd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sd.connect((host, port))
except socket.error:
self.outq.put((host, port, ’KAPALI’))
else:
self.outq.put((host, port, ’ACIK’))
sd.close()

def scan(host, start, stop, nthreads=MAX_THREADS):
toscan = Queue.Queue()
scanned = Queue.Queue()

scanners = [Scanner(toscan, scanned) for i in range(nthreads)]
for scanner in scanners:
scanner.start()

hostports = [(host, port) for port in xrange(start, stop+1)]
for hostport in hostports:
toscan.put(hostport)

results = {}
for host, port in hostports:
while (host, port) not in results:
nhost, nport, nstatus = scanned.get()
results[(nhost, nport)] = nstatus
status = results[(host, port)]
print ’%s:%d %s’ % (host, port, status)

# Taranacak Portların Bilgisi Kullanıcıdan Alınıyor

Baslangic_Port = int( raw_input("Taramaya Baslanacak Portu Giriniz: "))
Bitis_Port = int( raw_input("Taramanin Bitecegi Portu Giriniz: "))

# Port Taraması Yapılacak IP Adresini Kullanıcıdan Alınıyor

host = raw_input("Port Taramasi Yapilacak IP Adresini Giriniz: ")

if __name__ == ’__main__’:
scan(’%s’ %(host), Baslangic_Port, Bitis_Port)
print ""
raw_input(’Programdan cikmak icin "Enter" tusuna basin’)
__________________

Click the image to open in full size.
Kerem388 is offline Kerem388 isimli üyenin yazdığı bu Mesajı değerlendirin.   Alıntı ile Cevapla