Below is the code of what is probably useless but a functional IPv6 host scanner written in Python using threading.
To perform a regular (brute force) network scans in an IPv6 Network is almost impossible it can take over 5.000 years to finish.
This project was purely academic and I just wanted to learn about threading in Python.
This software is not recommended for general usage.....
This script will call the OS to actually perform the ping
This software receives two parameters:
a) Prefix to scan in the format 2001:db8::/64 (subnet, not host)
b) Number of simultaneous processes it can run (MAXPINGS)
One more time it was purely academic stuff but hopefully it can make your day
Finally, AFAIK nmap does not yet support IPv6 network scan.
The code written in python3:
--- cut here ---
#!/usr/bin/python3
import threading
import sys
import ipaddress
import subprocess
import time
CURRENTPINGS=0 # Number of simultaneous ping at a time
def DOPING6(IPv6ADDRESS):
global MAXPINGS, CURRENTPINGS
CURRENTPINGS+=1
CMD="ping6 -c 3 "+str(IPv6ADDRESS) + " 2> /dev/null > /dev/null"
return_code = subprocess.call(CMD, shell=True)
if return_code == 0: #If ping was succesful
print (IPv6ADDRESS," is alive")
CURRENTPINGS-=1
def main():
global MAXPINGS, CURRENTPINGS
if len(sys.argv) != 3: #Validate how many parameters we are receiving
print(" Not enough or too many parameter")
print(" Usage: ./scanipv6.py IPv6Prefix/lenght MAXPINGS")
print(" Example: ./scanipv6.py 2001:db8::/64 20")
print(" Prefix lenght can be between 64-128")
print(" MAXPINGS corresponds to how many pings will be running at the same time")
exit()
SUBNET,MASK=sys.argv[1].split("/")
MAXPINGS=int(sys.argv[2])
for addr in ipaddress.IPv6Network(sys.argv[1]): #Let's loop for each address in the Block
ping_thread=threading.Thread(target=DOPING6,args=(addr,))
while CURRENTPINGS >= MAXPINGS: # With this while we make it possible to run max simultaneous pings
time.sleep(1) # Let's wait one second before proceeding
#print ("Interrumping...., CURRENTPINGS > MAXPINGS") #Uncomment this line just for debugging
ping_thread.start()
main()
Site dedicated mainly to internetworking. The goal is to share experiences, teach IP, IPv6. Talk about Linux, IP services, servers, promote IPv6 adoption, routing protocols, security and in some cases just some thoughts. Keywords: linux, cisco, ospf, bgp, eigrp, ip, ipv6, sla, link, routers, routings, telco, telecommunications, security, ipv4
Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts
Monday, December 8, 2014
Monday, January 28, 2013
Installing Linux in a Sun Fire Server
Introduction:
The following describes the procedure for installing the operating system Debian GNU / Linux on a Sun Fire V210 Hardware.
First:
* As we know, this has not Hardware Out Video Card VGA or PS2 port for Keyboard. What if it has a serial port for Management.
* This server is 64-bit SPARC architecture.
Procedure:
1. - Download Image.
You can download the distro from http://cdimage.debian.org/debian-cd/6.0.3/sparc/iso-cd/
You will need least CD number 1
Then downloaded ISO: http://cdimage.debian.org/debian-cd/6.0.3/sparc/iso-cd/debian-6.0.3-sparc-CD-1.iso
Please remember to burn the image a low speed, it's good to avoid some drawbacks.
2.- Place the Debian CD image to the CD / DVD ROM Server.
3. - Now, we must establish a connection via Serial COM with the Sun Fire V210 server.
We can use Hyperterminal, Minicom or even PuTTYtel.
To create the serial connection you will need the following parameters:
9600,8, n, 1 (Default).
The cable is a cable type used Rollover (NOT crossover). Typically console cables Cisco equipment will work.
3. - Start the server. The challenge is to make Boot from CDROM drive.
To do this, do the following: When the server is starting, we pressed Sequence 'STOP + A'.
In a conventional keyboard, this sequence is the same as 'CTRL + SHIFT + BREAK' or 'CTRL + BREAK'.
In doing so, you will get PROMPT {} Ok, when that happens we do the following:
{} Ok printenv auto-boot (To see the State Flag of the auto-boot)
{} Ok setenv auto-boot false (for setting the auto-boot Flag False)
{} Ok reset-all (Reboot the System)
4. - When the computer restarts, return to Press 'STOP + A', and at the prompt {} Ok we do isinstructed to do Boot from CDROM, so:{} Ok boot cdrom
4.- From that moment, the server should begin to start from the CDROM drive. I recommend to use the terminal in Full Screen mode to see the installation as if it were a monitor connected to the server.
5.- From this point, it follows exactly the Debian installation procedure (Users, Partitions, Repositories, etc..)
Key Points:- Download the ISO image for SPARC 64.- The sequence 'STOP + A', which can be also 'CTRL + BRAK' or 'CTRL + SHIFT + BREAK'.- Place the screen in full screen.- If at any time the connection is lost Serial (usual with PuTTYtel), simply close and reopen theSerial Connection and type any key to recover the installation.- The system boots from the CDROM cuandl being the PROMPT {} Ok you type 'boot cdrom (Very Important ...!)
- To start the server automatically is necessary in ok prompt type the following:
auto-boot? = trueboot-device = disk
I hope it is useful.
Manual based on documentation of Professor Jose Gregorio Cotua
The following describes the procedure for installing the operating system Debian GNU / Linux on a Sun Fire V210 Hardware.
First:
* As we know, this has not Hardware Out Video Card VGA or PS2 port for Keyboard. What if it has a serial port for Management.
* This server is 64-bit SPARC architecture.
Procedure:
1. - Download Image.
You can download the distro from http://cdimage.debian.org/debian-cd/6.0.3/sparc/iso-cd/
You will need least CD number 1
Then downloaded ISO: http://cdimage.debian.org/debian-cd/6.0.3/sparc/iso-cd/debian-6.0.3-sparc-CD-1.iso
Please remember to burn the image a low speed, it's good to avoid some drawbacks.
2.- Place the Debian CD image to the CD / DVD ROM Server.
3. - Now, we must establish a connection via Serial COM with the Sun Fire V210 server.
We can use Hyperterminal, Minicom or even PuTTYtel.
To create the serial connection you will need the following parameters:
9600,8, n, 1 (Default).
The cable is a cable type used Rollover (NOT crossover). Typically console cables Cisco equipment will work.
3. - Start the server. The challenge is to make Boot from CDROM drive.
To do this, do the following: When the server is starting, we pressed Sequence 'STOP + A'.
In a conventional keyboard, this sequence is the same as 'CTRL + SHIFT + BREAK' or 'CTRL + BREAK'.
In doing so, you will get PROMPT {} Ok, when that happens we do the following:
{} Ok printenv auto-boot (To see the State Flag of the auto-boot)
{} Ok setenv auto-boot false (for setting the auto-boot Flag False)
{} Ok reset-all (Reboot the System)
4. - When the computer restarts, return to Press 'STOP + A', and at the prompt {} Ok we do isinstructed to do Boot from CDROM, so:{} Ok boot cdrom
4.- From that moment, the server should begin to start from the CDROM drive. I recommend to use the terminal in Full Screen mode to see the installation as if it were a monitor connected to the server.
5.- From this point, it follows exactly the Debian installation procedure (Users, Partitions, Repositories, etc..)
Key Points:- Download the ISO image for SPARC 64.- The sequence 'STOP + A', which can be also 'CTRL + BRAK' or 'CTRL + SHIFT + BREAK'.- Place the screen in full screen.- If at any time the connection is lost Serial (usual with PuTTYtel), simply close and reopen theSerial Connection and type any key to recover the installation.- The system boots from the CDROM cuandl being the PROMPT {} Ok you type 'boot cdrom (Very Important ...!)
- To start the server automatically is necessary in ok prompt type the following:
auto-boot? = trueboot-device = disk
I hope it is useful.
Manual based on documentation of Professor Jose Gregorio Cotua
Saturday, January 12, 2013
Error 1017 in Cacti. MySQL. Blank Graphics
Error:
4/7/2012 5:37:49 PM - CMDPHP: Poller [0] ERROR: SQL Cell Failed!, Error: '1017 ', SQL: "SELECT count (*) FROM polle
WHERE r_time poller_id = 0 AND end_time> '0000-00-00 00:00:00 '"
4/7/2012 5:38:34 PM - CMDPHP: Poller [0] ERROR: SQL Cell Failed!, Error: '1017 ', SQL: "SELECT count (*) FROM polle
r_time WHERE end_time = '0000-00-00 00:00:00 '"
Procedure:
If the file cacti.log you see the above error tt indicates a failure with poller_output mysql table.
In this respect, I have seem three different solutions, order from the less risky to the highest.
1) Repair mysql table with a php script that brings cacti
# php $PATH-TO-CACTI/cli/repair_database.php
2) Repair the table with mysql command:
# mysql> REPAIR TABLE poller_output;
If you do not know the user information for the mysql database, it can be found here:
$PATH-TO-CACTI/include/config.php
3) Remove the table and do it again (this solution despite being aggressive works perfectly and you do not lose the historic Cacti information). Just enters the mysql CLI and copy/paste the following:
-
- Table structure for table `poller_output`
-
DROP TABLE IF EXISTS `poller_output`;
CREATE TABLE `poller_output` (
MEDIUMINT local_data_id `` (8) unsigned NOT NULL default '0 ',
Rrd_name `` varchar (19) NOT NULL default'',
`Time` datetime NOT NULL default '0000-00-00 00:00:00 ',
`Output` text NOT NULL,
PRIMARY KEY (`local_data_id`, `rrd_name`, `time`)
) TYPE = MyISAM;
-
- Dumping data for table `poller_output`
-
Poller_output `LOCK TABLES` WRITE;
/ *! 40000 ALTER TABLE `poller_output` DISABLE KEYS * /;
/ *! 40000 ALTER TABLE `poller_output` ENABLE KEYS * /;
UNLOCK TABLES;
Ready!, Then you can wait for the poller runs 15 minutes and you will have something in your graphs. If you want to force the poller command is as follows:
# /usr/bin/php-q /var /www/miServer-cacti/poller.php -force
I hope it will be useful,
4/7/2012 5:37:49 PM - CMDPHP: Poller [0] ERROR: SQL Cell Failed!, Error: '1017 ', SQL: "SELECT count (*) FROM polle
WHERE r_time poller_id = 0 AND end_time> '0000-00-00 00:00:00 '"
4/7/2012 5:38:34 PM - CMDPHP: Poller [0] ERROR: SQL Cell Failed!, Error: '1017 ', SQL: "SELECT count (*) FROM polle
r_time WHERE end_time = '0000-00-00 00:00:00 '"
Procedure:
If the file cacti.log you see the above error tt indicates a failure with poller_output mysql table.
In this respect, I have seem three different solutions, order from the less risky to the highest.
1) Repair mysql table with a php script that brings cacti
# php $PATH-TO-CACTI/cli/repair_database.php
2) Repair the table with mysql command:
# mysql> REPAIR TABLE poller_output;
If you do not know the user information for the mysql database, it can be found here:
$PATH-TO-CACTI/include/config.php
3) Remove the table and do it again (this solution despite being aggressive works perfectly and you do not lose the historic Cacti information). Just enters the mysql CLI and copy/paste the following:
-
- Table structure for table `poller_output`
-
DROP TABLE IF EXISTS `poller_output`;
CREATE TABLE `poller_output` (
MEDIUMINT local_data_id `` (8) unsigned NOT NULL default '0 ',
Rrd_name `` varchar (19) NOT NULL default'',
`Time` datetime NOT NULL default '0000-00-00 00:00:00 ',
`Output` text NOT NULL,
PRIMARY KEY (`local_data_id`, `rrd_name`, `time`)
) TYPE = MyISAM;
-
- Dumping data for table `poller_output`
-
Poller_output `LOCK TABLES` WRITE;
/ *! 40000 ALTER TABLE `poller_output` DISABLE KEYS * /;
/ *! 40000 ALTER TABLE `poller_output` ENABLE KEYS * /;
UNLOCK TABLES;
Ready!, Then you can wait for the poller runs 15 minutes and you will have something in your graphs. If you want to force the poller command is as follows:
# /usr/bin/php-q /var /www/miServer-cacti/poller.php -force
I hope it will be useful,
Labels:
cacti,
linux,
monitoring,
mysql,
scripts
Saturday, January 5, 2013
Disable / shutdown iptables on Linux
Introduction:
Sometimes it is necessary to "shutdown" or disable our Linux iptables,
the procedure depends on the Linux distribution you're using.
1) Procedure if you are using Redhat, Fedora, Mandriva / Mandrake or Centos, you just have to run the following:
# service iptables save
# service iptables stop
# chkconfig iptables off
or
# / etc /init.d/iptables stop
2) How to disable iptables on Debian or Ubuntu
a) Create a script called fw.stop with the following contents:
# /bin/sh
echo "Stopping firewall and Allowing everyone ..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
b) Give execute permission to the script:
# chmod + x / root / fw.stop
or
# chmod 755 fw.stop
c) You can run the scritp with the following command:
# ./fw.stop
More info at:
http://sources68.com/linux-disable-remove-the-iptables-firewall-1fa67761.html
# service iptables save
# service iptables stop
# chkconfig iptables off
or
# / etc /init.d/iptables stop
2) How to disable iptables on Debian or Ubuntu
a) Create a script called fw.stop with the following contents:
# /bin/sh
echo "Stopping firewall and Allowing everyone ..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
b) Give execute permission to the script:
# chmod + x / root / fw.stop
or
# chmod 755 fw.stop
c) You can run the scritp with the following command:
# ./fw.stop
More info at:
http://sources68.com/linux-disable-remove-the-iptables-firewall-1fa67761.html
Subscribe to:
Posts (Atom)