Hab mir mal wieder die Zeit genommen meinen SSH Honeypot auszuwerten
Was ich noch nicht heraus gefunden habe ist, wieso die meisten Angriffsversuche aus China kommen
#!/bin/bash/python
# -*- coding: utf8 -*-
from random import randint
a= randint(1,2)
if a ==1:
print“Ja“
else:
print“Nein“
# -*- coding: utf8 -*-
import os
#os.system(„ps -A |grep -c ssh“)
name = (raw_input(„Wie heißt du:“))
print name
os.system(„say Hallo „+name +“ ,wie geht es dir“)
#!/usr/bin/python
# This is a simple port-forward / proxy, written using only the default python
# library. If you want to make a suggestion or fix something you can contact-me
# at voorloop_at_gmail.com
# Distributed over IDC(I Don’t Care) license
import socket
import select
import time
import sys
# Changing the buffer_size and delay, you can improve the speed and bandwidth.
# But when buffer get to high or delay go too down, you can broke things
buffer_size = 4096
delay = 0.0001
forward_to = (’smtp.zaz.ufsk.br‘, 25)
class Forward:
def __init__(self):
self.forward = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
def start(self, host, port):
try:
self.forward.connect((host, port))
return self.forward
except Exception, e:
print e
return False
class TheServer:
input_list = []
channel = {}
def __init__(self, host, port):
self.server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.server.bind((host, port))
self.server.listen(200)
def main_loop(self):
self.input_list.append(self.server)
while 1:
time.sleep(delay)
ss = select.select
inputready, outputready, exceptready = ss(self.input_list, [], [])
for self.s in inputready:
if self.s == self.server:
self.on_accept()
break
self.data = self.s.recv(buffer_size)
if len(self.data) == 0:
self.on_close()
else:
self.on_recv()
def on_accept(self):
forward = Forward().start(forward_to[0], forward_to[1])
clientsock, clientaddr = self.server.accept()
if forward:
print clientaddr, „has connected“
self.input_list.append(clientsock)
self.input_list.append(forward)
self.channel[clientsock] = forward
self.channel[forward] = clientsock
else:
print „Can’t establish connection with remote server.“,
print „Closing connection with client side“, clientaddr
clientsock.close()
def on_close(self):
print self.s.getpeername(), „has disconnected“
#remove objects from input_list
self.input_list.remove(self.s)
self.input_list.remove(self.channel[self.s])
out = self.channel[self.s]
# close the connection with client
self.channel[out].close() # equivalent to do self.s.close()
# close the connection with remote server
self.channel[self.s].close()
# delete both objects from channel dict
del self.channel[out]
del self.channel[self.s]
def on_recv(self):
data = self.data
# here we can parse and/or modify the data before send forward
print data
self.channel[self.s].send(data)
if __name__ == ‚__main__‘:
server = TheServer(“, 9090)
try:
server.main_loop()
except KeyboardInterrupt:
print „Ctrl C – Stopping server“
sys.exit(1)
<?php
function get_metar($station)
{
$fileName = „ftp://tgftp.nws.noaa.gov/data/observations/metar/stations/$station.TXT“;
$metar = “;
$fileData = @file($fileName); // or die(‚Data not available‘);
if ($fileData != false)
{
list($i, $date) = each($fileData);
while (list($i, $line) = each($fileData))
{
$metar .= ‚ ‚ . trim($line);
}
$metar = trim(str_replace(‚ ‚, ‚ ‚, $metar));
}
return $metar;
}
$dep_station = „LOWI“;
$dep_metar = get_metar($dep_station);
echo $dep_metar;
?>
Da es mir meist zu mühsam ist den kompletten Befehl + ip usw. für ssh einzugeben habe ich das ganze einfach in ein Script gepackt:
#!/usr/bin/python
# -*- coding: utf8 -*-
import os
print „Auswahl:“
print „a: 10.0.10.130(Lokal oder VPN)“
print „b: 10.0.10.129 (Lokal oder VPN)“
print „c: 10.0.10.144 (Lokal oder VPN)“
print „d: Exit“
sel = (raw_input(„Select System:“))
a = „ssh -p 10022 -l pi 10.0.10.130“
b = „ssh -l pi 10.0.10.129“
c = „ssh -l pi 10.0.10.144“
if sel == „a“:
print a
os.system(a)
elif sel == „b“:
print b
os.system(b)
elif sel == „c“:
print c
os.system(c)
elif sel == „d“:
print „Disconnect“
exit()
else:
print „Error“
Heute in der früh zufällig festgestellt das die Temperaturerfassung seit 2200 nicht mehr funktioniert hat.
Grund des Problemes war wohl ein Einbruchsversuch in meinen SQL Server
mysqladmin -umyname -pmypassword flush-hosts hat das Problem aber schnell gelöst.
Habe jetzt mal probeweise die max_connects raufgesetzt, das Logging angepasst
und den rest erledigt hoffentlich fail2ban und die portsentrys.
Desweiteren werd ich wohl ein reporting Script schreiben welches mich per Mail über Fehler informiert
Quelle: Jordanopensource.org