Documentation
This library has three different files:
- singsing.c (core)
- singsing.h (public headers)
- singsing_p.h (private headers)
To use singsing within your project you have to include the public header:
#include "singsing.h"
| OS | Compiling command |
|---|---|
| Linux | gcc -o program_name prog.c singsing.c -lpcap -lpthread -Wall |
| Solaris | gcc -o program_name prog.c singsing.c -lpcap -lpthread -Wall -DSOLARIS -lxnet -lsocket |
| Mac OS X | gcc -o program_name prog.c singsing.c -lpcap -lpthread -Wall -DMAC |
void singsing_create( struct singsing_descriptor * )
Inizialize singsing descriptor structure.int singsing_add_port( struct singsing_descriptor *, unsigned int )
Add port to scan.singsing_add_port( &fd, 22 ); singsing_add_port( &fd, 23 ); singsing_add_port( &fd, 110 );
int singsing_set_scan_interface( struct singsing_descriptor *, char * )
Set the scanning interface.singsing_set_scan_interface( &fd, "eth0" );
int singsing_set_scan_host( struct singsing_descriptor *, char * )
Set the scanning target using CIDR notation.singsing_set_scan_host( &fd, "192.168.0.1/24" );
void singsing_set_bandwidth( struct singsing_descriptor *, int )
Set the bandwidth used for sending SYN. The default is 15KB/s. It seems that using more than 70KB/s causes the Linux kernel to have problems sending packets.singsing_set_bandwidth( &fd, 10 );
void singsing_set_scanmode( struct singsing_descriptor *, int )
Set the scanning options. Check scan options page for more details.singsing_set_scanmode( &fd, SINGSING_NODUPS_SCAN );
singsing_set_scanmode( &fd, SINGSING_SEGMENT_SCAN );
int singsing_init( struct singsing_descriptor * )
Start the scan.| Return code | Meaning |
|---|---|
| 0 | Scan succefully started |
| -1 | Scanning host/net not set |
| -2 | Scanning port not set |
| -3 | Scanning interface not set |
int singsing_scanisfinished( struct singsing_descriptor * )
Check if the scan is ended.| Return code | Meaning |
|---|---|
| 0 | Scan is in progress |
| 1 | All SYN havs been sent, waiting for replies |
| 2 | Scan ended |
void singsing_get_status( struct singsing_descriptor * , struct singsing_status_struct )
Get current scanning status, the singsing_status_struct has these members:
| Variable | Meaning |
|---|---|
| unsigned long total_port | total number of SYN that should be sent before ending the scan |
| unsigned long current_port | number of sent SYN |
| unsigned long synps | SYN/s |
| time_t init_time | start scan time |
| time_t current_time | current time |
struct singsing_status_struct current_status; singsing_get_status(&fd, ¤t_status);
struct singsing_result_queue * singsing_get_result( struct singsing_descriptor * )
Get the scanning results. If the return value is NULL the queue is currently empty. Remember, the result will be pushed on dynamic memory, so you have to free it!struct singsing_result_queue * cur_res; cur_res = singsing_get_result(&fd);
free( cur_res );
void singsing_destroy( struct singsing_descriptor * )
Free internal structures.