#!/bin/bash
#WORK ON DEBIAN BASE SYSTEM!
#CHECK USER IS ROOT OR NOT
if [ $UID -ne 0 ];then
echo "Must run with root privileg!!!"
exit
fi
#GET NETWORK INTERFACE
network=$(ifconfig | sed '1!d' | cut -d" " -f1)
#CHECK NETWORK INTERFACE IS ADD TO PARAM IN SCRIPT
if [ "$#" -ne 1 ];then
echo "Usage - ./ping.sh $network"
exit
fi
#CHECK NBTSCANEXISTS OR NOT
test `which nbtscan` || \
echo -e "Error nbtscan not exists\nTry to install!!!" `apt-get install nbtscan` >> /dev/null
interface=$1
echo "The interface is $interface"
prefix=$(ifconfig $interface | grep "inet addr" | cut -d ":" -f2 | cut -d " " -f1 | cut -d"." -f1-3)
echo "------------------------------------------------------------"
for addr in $(seq 1 254);do
nbtscan $prefix.$addr | grep -E "server" | awk -F" " '{printf "%-15s %-20s %s\n", $1,$2,$NF}' &
done
26.08.2016 г.
22.08.2016 г.
Ban all IPs that attempted to access to ssh without success
grep sshd /var/log/auth.log | \
grep -Eo 'rhost=([1-2]?[0-9]{0,2}\.){3,3}[1-2]?[0-9]{0,2}' | \
awk -F"=" '{print $2}' | sort | uniq -c |sort -k2nr | \
awk '$1>3 {print $2}' |\
xargs -I% sudo iptables -A INPUT -s % -j DROP
grep -Eo 'rhost=([1-2]?[0-9]{0,2}\.){3,3}[1-2]?[0-9]{0,2}' | \
awk -F"=" '{print $2}' | sort | uniq -c |sort -k2nr | \
awk '$1>3 {print $2}' |\
xargs -I% sudo iptables -A INPUT -s % -j DROP
Serch for duplicated file's (!!!Not Erased only show!!!)
##################################################
# Search for duplicated files without, #
# meaningless file exstension #
# NOT EDIT BY HAND!!! ONLY Dir Param #
##################################################
#IMPORT MODULES FOR SCRIPT
import hashlib, os
from itertools import *
from operator import itemgetter
#THIS USE FOR GIVE MD5 FOR FILE'S
md = hashlib.md5()
#Directory = os.getcwd()
#ADD NEEDED LIST
Dir = "C:\\script\\"
_File = [] #CONTAINED PATH FOR FILE
_File_H = [] #CONTAINED MD5 CODE FOR FILE
_duplicated = [] #CONTAINED DUPLIATED
_duplicated_sravnqva = [] #NEED FOR ZIP
subdirlist = [] #MAY DELETED IF YOU WON USED FOR FUNCTION search_file
#SEARCH WITH OS.WALK
def search_os_walk(Dir):
for path,dirlist,filelist in os.walk(Dir):
for fn in filelist:
try:
yield os.path.join(path,fn)
except IOError, e:
print "Not allowed", e
#FUNCTION USE FOR ENCRIPT FILE TO MD5
def md_5(filePath):
try:
with open(filePath, 'rb') as fh:
m = hashlib.md5()
while True:
try:
data = fh.read(8192)
if not data:
break
m.update(data)
except IOError, e:
print "Not allowerd Basi", e
return m.hexdigest()
except IOError, e:
print "Not allowerd", e
#SEARCH FOR FILE AND APPEND THEM TO REQUIRED LIST (LOOKED ABOVE FOR #DESCRIPTION'S )
for file in search_os_walk(Dir):
_File.append(file)
_File_H.append(md_5(file))
for f,z in (izip(_File, _File_H)):
if z in _duplicated:
_duplicated_sravnqva.append(z)
_duplicated.append(z)
print "*"*80
_Dupliated = [x[0] for x in zip(_File, _File_H) if x[1] in _duplicated_sravnqva]
one= []
two= []
for i in _Dupliated:
one.append(i)
two.append(md_5(i))
#RESULT IN DICTIONARI, NEEDED FOR FUNCTION GROUPBY
d = dict(zip(one,two))
di = sorted(d.iteritems(), key=itemgetter(1))
for k, g in groupby(di, key=itemgetter(1)):
#IF YOU WHANT TO SHOW IN COLUMN UNCHECK BOTTOM ROW'S
# for i,z in enumerate(map(itemgetter(0), g)):
# print i,z
print "Duplicated ", map(itemgetter(0), g)
#raw_input()
14.08.2016 г.
Python generate file with password
# -*- coding:utf-8 -*-
#IMPORT MODULE
import itertools
from itertools import islice
#FILE TO WRITE RESULT
File = "password_list.txt"
#FUNCTION GENERATE PASSWORD WORD'S
def generate():
for z in xrange(3,9):
res = itertools.product('abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@', repeat=z)
for i in res:
r = "".join(i)
yield r
#WRITE WORD IN FILE
with open(File, 'w') as f:
for s in generate():
f.write("{}\n".format(s))
#IF YOU WANT TO READ A FILE SECOND FUNCTION DO THIS
#UNCOMENT ROW FOR WORK WITH!
# with open(File, 'r') as f:
# while True:
# next_line = list(islice(f, 1000))
# if not next_line:
# break
# for line in next_line:
# print line.strip()
12.08.2016 г.
Тест дали има пинг до масхина и изпращане на email при падане.
# -*- coding: utf-8 -*-
#IMPORT SOMTHING MODULES########################
import os, subprocess, time ##
from sys import platform ##
import smtplib ##
################################################
#HARDCORE CONST'S#########################################
PING='' ##
TARGET = '192.168.1.9' ##
MASHINE = ' ' ##
TAKE_STATUS = [] ##
TIME_TO_SLEEP = time.sleep(10) ##
sender = 'email address' ##
receivers = ['korea60@abv'] ##
message = """From: From Server - name
To: To Person
Subject: IP is down in {}
""".format(time.asctime(time.localtime(time.time())))
##########################################################
#DEFINE FUNCTION'S IS HERE
#1 TEST MASHINE VERSION
def check_mashine():
global MASHINE
global PING
if platform.startswith('lin'):
MASHINE = ' -c1'
PING='/bin/ping'
else:
MASHINE = ' -n1'
PING='ping'
#2 PING TARGET MASHINE AND COLLECT STATUS
def check_ping():
global TAKE_STATUS
check_mashine()
RESPONSE = os.system("{}{} {} > /dev/null".format(PING,MASHINE,TARGET))
if RESPONSE:
TAKE_STATUS.append("1")
else:
pass
#3 SEND EMAIL
def send_emain():
mailserver = smtplib.SMTP('smtp.gmail.com:587')
# Identifikaciq
mailserver.ehlo()
# secure our email
mailserver.starttls()
# re-identify ourselves as an encrypted connection
mailserver.ehlo()
mailserver.login('username is here!!!!', 'password is here !!!!')
mailserver.sendmail('from','to',message)
#ZATVARQME SYRVARA
mailserver.quit()
#TAKE THE MAGIC!!!
if __name__ == '__main__':
while len(TAKE_STATUS) < 5:
check_ping()
TIME_TO_SLEEP
send_emain()
print ("MAIL SEND")
9.08.2016 г.
VNC auto start
1 . x11vnc -auth /tmp/.Xauth1000 -forever -rfbauth /home/folder/x11vnc.pass -rfbport 5900
2 . x11vnc -nap -wait 5 -noxdamage -pasword "password" -display :0 -forever
2 . x11vnc -nap -wait 5 -noxdamage -pasword "password" -display :0 -forever
3.08.2016 г.
How long proccess is started.
ps -p `top -b -n1 | grep firebi* | awk '{print $1}'` -o etime=
if row is more then one:
ps -p `top -b -n1 | grep firebi* | sed '1!d' | awk '{print $1}'` -o etime=
if row is more then one:
ps -p `top -b -n1 | grep firebi* | sed '1!d' | awk '{print $1}'` -o etime=
Абонамент за:
Публикации
(
Atom
)