mirror of
http://git.openwrt.org/packages.git
synced 2025-01-08 11:57:34 +08:00
netdiscover: moved to github
Signed-off-by: Luka Perkov <luka@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/packages@45763 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
d462377f56
commit
2c3a34118b
@ -1,41 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2009-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=netdiscover
|
||||
PKG_VERSION:=0.3-beta6
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://nixgeneration.com/~jaime/netdiscover/releases/
|
||||
PKG_MD5SUM:=0919227a91ecaeeb2443cff249417be2
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/netdiscover
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+libpcap +libnet1 +libpthread
|
||||
TITLE:=An active/passive address reconnaissance tool
|
||||
URL:=http://nixgeneration.com/~jaime/netdiscover/
|
||||
MAINTAINER:=Daniel Dickinson <openwrt@cshore.neomailbox.net>
|
||||
endef
|
||||
|
||||
CONFIGURE_VARS+= \
|
||||
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(STAGING_DIR)/usr/lib/libnet-1.1.x/include" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib/libnet-1.1.x/lib" \
|
||||
|
||||
define Package/netdiscover/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/netdiscover $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,netdiscover))
|
@ -1,467 +0,0 @@
|
||||
diff -Naur netdiscover-0.3-beta6.orig/src/ifaces.c netdiscover-0.3-beta6/src/ifaces.c
|
||||
--- netdiscover-0.3-beta6.orig/src/ifaces.c 2009-06-24 18:21:11.000000000 -0400
|
||||
+++ netdiscover-0.3-beta6/src/ifaces.c 2009-06-24 21:44:05.000000000 -0400
|
||||
@@ -127,6 +127,7 @@
|
||||
memcpy(type, packet + 20, 2); /* ARP Opcode */
|
||||
new_arprep_l->header = new_header; /* Add header */
|
||||
new_arprep_l->count = 1; /* Count */
|
||||
+ new_arprep_l->printed = 0;
|
||||
new_arprep_l->next = NULL;
|
||||
|
||||
/* Source IP */
|
||||
diff -Naur netdiscover-0.3-beta6.orig/src/main.c netdiscover-0.3-beta6/src/main.c
|
||||
--- netdiscover-0.3-beta6.orig/src/main.c 2009-06-24 18:21:11.000000000 -0400
|
||||
+++ netdiscover-0.3-beta6/src/main.c 2009-06-24 21:34:59.000000000 -0400
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+#include <signal.h>
|
||||
#include "ifaces.h"
|
||||
#include "screen.h"
|
||||
|
||||
@@ -39,8 +40,17 @@
|
||||
char *disp;
|
||||
char *sip;
|
||||
int autos;
|
||||
+ int machine;
|
||||
};
|
||||
|
||||
+/* Injection Thread data structure */
|
||||
+struct t_inject {
|
||||
+ struct t_data *datos;
|
||||
+ pthread_t *sniffer;
|
||||
+ pthread_t *screen;
|
||||
+ pthread_t *keys;
|
||||
+ int scan_secs;
|
||||
+};
|
||||
|
||||
void *inject_arp(void *arg);
|
||||
void *screen_refresh(void *arg);
|
||||
@@ -77,7 +87,7 @@
|
||||
|
||||
|
||||
pthread_t injection, sniffer, screen, keys;
|
||||
-int fastmode, pcount, node, ssleep;
|
||||
+int fastmode, pcount, node, ssleep, nokeywait;
|
||||
long sleept;
|
||||
|
||||
|
||||
@@ -86,7 +96,9 @@
|
||||
{
|
||||
while ( 1 == 1 )
|
||||
{
|
||||
- read_key();
|
||||
+ struct t_data *datos;
|
||||
+ datos = (struct t_data *)arg;
|
||||
+ read_key(datos->machine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,20 +109,24 @@
|
||||
int c;
|
||||
int esniff = 0;
|
||||
int erange = 0;
|
||||
+ int scan_secs = 0;
|
||||
struct t_data datos;
|
||||
-
|
||||
+ struct t_inject injectdata;
|
||||
+
|
||||
datos.sip = NULL;
|
||||
datos.disp = NULL;
|
||||
+ datos.machine = 0;
|
||||
datos.autos = 0;
|
||||
sleept = 99;
|
||||
node = 67;
|
||||
pcount = 1;
|
||||
+ nokeywait = 0;
|
||||
|
||||
current_network = (char *) malloc ((sizeof(char)) * 16);
|
||||
sprintf(current_network,"Starting.");
|
||||
|
||||
/* Fetch parameters */
|
||||
- while ((c = getopt(argc, argv, "i:s:r:n:c:pSfh")) != EOF)
|
||||
+ while ((c = getopt(argc, argv, "i:s:r:n:c:t:pSfhkm")) != EOF)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@@ -138,12 +154,20 @@
|
||||
case 'n':
|
||||
node = atoi(optarg);
|
||||
break;
|
||||
+
|
||||
+ case 't':
|
||||
+ scan_secs = atoi(optarg);
|
||||
+ break;
|
||||
|
||||
case 'r':
|
||||
datos.sip = (char *) malloc (sizeof(char) * strlen(optarg));
|
||||
sprintf(datos.sip, "%s", optarg);
|
||||
erange = 1;
|
||||
break;
|
||||
+
|
||||
+ case 'm':
|
||||
+ datos.machine = 1;
|
||||
+ break;
|
||||
|
||||
case 'f':
|
||||
fastmode = 1;
|
||||
@@ -153,6 +177,10 @@
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
break;
|
||||
+
|
||||
+ case 'k':
|
||||
+ nokeywait = 1;
|
||||
+ break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -181,7 +209,7 @@
|
||||
/* Init some stuff */
|
||||
lnet_init(datos.disp);
|
||||
init_lists();
|
||||
- system("clear");
|
||||
+ if (!datos.machine) system("clear");
|
||||
|
||||
/* If no mode was selected, enable auto scan */
|
||||
if ((erange != 1) && (esniff != 1))
|
||||
@@ -189,9 +217,15 @@
|
||||
datos.autos = 1;
|
||||
}
|
||||
|
||||
+
|
||||
/* Start the execution */
|
||||
- pthread_create(&screen, NULL, screen_refresh, (void *)NULL);
|
||||
- pthread_create(&keys, NULL, keys_thread, (void *)NULL);
|
||||
+ pthread_create(&screen, NULL, screen_refresh, (void *)&datos);
|
||||
+ if (!nokeywait) {
|
||||
+ pthread_create(&keys, NULL, keys_thread, (void *)&datos);
|
||||
+ injectdata.keys = &keys;
|
||||
+ } else {
|
||||
+ injectdata.keys = NULL;
|
||||
+ }
|
||||
pthread_create(&sniffer, NULL, start_sniffer, (void *)&datos);
|
||||
|
||||
if (esniff == 1)
|
||||
@@ -201,10 +235,19 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
- if (pthread_create(&injection, NULL, inject_arp, (void *)&datos))
|
||||
+ injectdata.datos = &datos;
|
||||
+ injectdata.sniffer = &sniffer;
|
||||
+ injectdata.screen = &screen;
|
||||
+ injectdata.scan_secs = scan_secs;
|
||||
+
|
||||
+ if (pthread_create(&injection, NULL, inject_arp, (void *)&injectdata))
|
||||
perror("Could not create injection thread");
|
||||
|
||||
- pthread_join(sniffer,NULL);
|
||||
+ if (scan_secs > 0) {
|
||||
+ pthread_join(injection,NULL);
|
||||
+ } else {
|
||||
+ pthread_join(sniffer,NULL);
|
||||
+ }
|
||||
}
|
||||
|
||||
|
||||
@@ -215,10 +258,11 @@
|
||||
/* Refresh screen function called by screen thread */
|
||||
void *screen_refresh(void *arg)
|
||||
{
|
||||
-
|
||||
+ struct t_data *datos;
|
||||
+ datos = (struct t_data *)arg;
|
||||
while (1==1)
|
||||
{
|
||||
- print_screen();
|
||||
+ print_screen(datos->machine);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
@@ -228,9 +272,11 @@
|
||||
/* Inject ARP Replys to the network */
|
||||
void *inject_arp(void *arg)
|
||||
{
|
||||
+ struct t_inject *inject;
|
||||
struct t_data *datos;
|
||||
|
||||
- datos = (struct t_data *)arg;
|
||||
+ inject = (struct t_inject *)arg;
|
||||
+ datos = inject->datos;
|
||||
sleep(2);
|
||||
|
||||
if ( datos->autos != 1 )
|
||||
@@ -251,6 +297,12 @@
|
||||
|
||||
sprintf(current_network,"Finished!");
|
||||
lnet_destroy();
|
||||
+ if (inject->scan_secs > 0) {
|
||||
+ sleep(inject->scan_secs);
|
||||
+ pthread_kill(*(inject->sniffer), SIGKILL);
|
||||
+ pthread_kill(*(inject->screen), SIGKILL);
|
||||
+ pthread_kill(*(inject->keys), SIGKILL);
|
||||
+ }
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -400,6 +452,9 @@
|
||||
" -n node: last ip octet used for scanning (from 2 to 253)\n"
|
||||
" -S enable sleep time supression betwen each request (hardcore mode)\n"
|
||||
" -f enable fastmode scan, saves a lot of time, recommended for auto\n\n"
|
||||
+ " -k nokeywait: Don't wait for keypress\n"
|
||||
+ " -t time: maximum time to listen after last arp request sent (seconds)\n"
|
||||
+ " -m don't clear and format screen, just output replies\n"
|
||||
"If -p or -r arent enabled, netdiscover will scan for common lan addresses\n",
|
||||
VERSION, comando);
|
||||
}
|
||||
diff -Naur netdiscover-0.3-beta6.orig/src/screen.c netdiscover-0.3-beta6/src/screen.c
|
||||
--- netdiscover-0.3-beta6.orig/src/screen.c 2009-06-24 18:21:11.000000000 -0400
|
||||
+++ netdiscover-0.3-beta6/src/screen.c 2009-06-25 19:15:24.000000000 -0400
|
||||
@@ -114,7 +114,7 @@
|
||||
|
||||
|
||||
/* Read input keys */
|
||||
-void read_key()
|
||||
+void read_key(int machine)
|
||||
{
|
||||
int ch;
|
||||
ch = getchar();
|
||||
@@ -162,12 +162,12 @@
|
||||
smode = 2;
|
||||
}
|
||||
|
||||
- print_screen();
|
||||
+ print_screen(machine);
|
||||
}
|
||||
|
||||
|
||||
/* Clear and fill the screen */
|
||||
-void print_screen()
|
||||
+void print_screen(int machine)
|
||||
{
|
||||
/* Get Console Size */
|
||||
if (ioctl(0, TIOCGWINSZ, &win_sz) < 0)
|
||||
@@ -177,16 +177,16 @@
|
||||
}
|
||||
|
||||
/* Flush and print screen */
|
||||
- fprintf( stderr, "\33[1;1H" );
|
||||
- fill_screen();
|
||||
- fprintf( stderr, "\33[J" );
|
||||
+ if (!machine) fprintf( stderr, "\33[1;1H" );
|
||||
+ fill_screen(machine);
|
||||
+ if (!machine) fprintf( stderr, "\33[J" );
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
/* Fills the screen using white spaces to avoid refresh problems *
|
||||
* not a very smart way, but it works :) */
|
||||
-void fill_screen()
|
||||
+void fill_screen(int machine)
|
||||
{
|
||||
int x, j;
|
||||
struct arp_rep_l *arprep_l;
|
||||
@@ -196,40 +196,42 @@
|
||||
|
||||
pthread_mutex_lock(listm);
|
||||
|
||||
- sprintf(line, " Currently scanning: %s | Our Mac is: %s - %i",
|
||||
- current_network, ourmac, scroll);
|
||||
- printf("%s", line);
|
||||
-
|
||||
- /* Fill with spaces */
|
||||
- for (j=strlen(line); j<win_sz.ws_col - 1; j++)
|
||||
- printf(" ");
|
||||
- printf("\n");
|
||||
-
|
||||
- /* Print blank line with spaces */
|
||||
- for (j=0; j<win_sz.ws_col - 1; j++)
|
||||
- printf(" ");
|
||||
- printf("\n");
|
||||
-
|
||||
-
|
||||
- sprintf(line, " %d Captured ARP Req/Rep packets, from %d hosts. Total size: %d",
|
||||
- arprep_count->count, arprep_count->hosts, arprep_count->length);
|
||||
- printf("%s", line);
|
||||
-
|
||||
- /* Fill with spaces */
|
||||
- for (j=strlen(line); j<win_sz.ws_col - 1; j++)
|
||||
- printf(" ");
|
||||
- printf("\n");
|
||||
-
|
||||
-
|
||||
- /* Print Header and counters */
|
||||
- printf(" _____________________________________________________________________________\n");
|
||||
- if (smode == 0 || (oldmode == 0 && smode == 2))
|
||||
- printf(" IP At MAC Address Count Len MAC Vendor \n");
|
||||
- else if (smode == 1 || (oldmode == 1 && smode == 2))
|
||||
- printf(" IP At MAC Address Requests IP Count \n");
|
||||
- printf(" ----------------------------------------------------------------------------- \n");
|
||||
-
|
||||
-
|
||||
+
|
||||
+ if (!machine) {
|
||||
+ sprintf(line, " Currently scanning: %s | Our Mac is: %s - %i",
|
||||
+ current_network, ourmac, scroll);
|
||||
+ printf("%s", line);
|
||||
+
|
||||
+ /* Fill with spaces */
|
||||
+ for (j=strlen(line); j<win_sz.ws_col - 1; j++)
|
||||
+ printf(" ");
|
||||
+ printf("\n");
|
||||
+
|
||||
+ /* Print blank line with spaces */
|
||||
+ for (j=0; j<win_sz.ws_col - 1; j++)
|
||||
+ printf(" ");
|
||||
+ printf("\n");
|
||||
+
|
||||
+
|
||||
+ sprintf(line, " %d Captured ARP Req/Rep packets, from %d hosts. Total size: %d",
|
||||
+ arprep_count->count, arprep_count->hosts, arprep_count->length);
|
||||
+ printf("%s", line);
|
||||
+
|
||||
+ /* Fill with spaces */
|
||||
+ for (j=strlen(line); j<win_sz.ws_col - 1; j++)
|
||||
+ printf(" ");
|
||||
+ printf("\n");
|
||||
+
|
||||
+
|
||||
+ /* Print Header and counters */
|
||||
+ printf(" _____________________________________________________________________________\n");
|
||||
+ if (smode == 0 || (oldmode == 0 && smode == 2))
|
||||
+ printf(" IP At MAC Address Count Len MAC Vendor \n");
|
||||
+ else if (smode == 1 || (oldmode == 1 && smode == 2))
|
||||
+ printf(" IP At MAC Address Requests IP Count \n");
|
||||
+ printf(" ----------------------------------------------------------------------------- \n");
|
||||
+ }
|
||||
+
|
||||
/* Print each found station trough arp reply */
|
||||
if (smode == 0)
|
||||
{
|
||||
@@ -243,12 +245,12 @@
|
||||
sprintf(tline, " ");
|
||||
|
||||
/* Set IP */
|
||||
- sprintf(tline, "%s ", arprep_l->sip);
|
||||
+ sprintf(tline, "%s ", arprep_l->sip);
|
||||
strcat(line, tline);
|
||||
-
|
||||
- /* Fill with spaces */
|
||||
- for (j=strlen(line); j<17; j++)
|
||||
- strcat(line, blank);
|
||||
+
|
||||
+ /* Fill with spaces */
|
||||
+ for (j=strlen(line); j<17; j++)
|
||||
+ strcat(line, blank);
|
||||
|
||||
/* IP & MAC */
|
||||
sprintf(tline, "%02x:%02x:%02x:%02x:%02x:%02x ",
|
||||
@@ -260,21 +262,29 @@
|
||||
/* Count, Length & Vendor */
|
||||
sprintf(tline, "%02d %03d %s", arprep_l->count,
|
||||
arprep_l->header->length, arprep_l->vendor );
|
||||
- strcat(line, tline);
|
||||
-
|
||||
- /* Fill again with spaces */
|
||||
- for (j=strlen(line); j<win_sz.ws_col - 1; j++)
|
||||
- strcat(line, blank);
|
||||
+ strcat(line, tline);
|
||||
|
||||
- printf("%s\n", line);
|
||||
+ /* Fill again with spaces */
|
||||
+ for (j=strlen(line); j<win_sz.ws_col - 1; j++)
|
||||
+ strcat(line, blank);
|
||||
+
|
||||
+ if (!arprep_l->printed) {
|
||||
+ printf("%s\n", line);
|
||||
+ arprep_l->printed = 1;
|
||||
+ if (!machine) {
|
||||
+ arprep_l->printed = 0;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
arprep_l = arprep_l->next;
|
||||
x += 1;
|
||||
-
|
||||
- /* Check if end of screen was reached */
|
||||
- if (x >= ( (win_sz.ws_row + scroll) - 7))
|
||||
- break;
|
||||
+
|
||||
+ if (!machine) {
|
||||
+ /* Check if end of screen was reached */
|
||||
+ if (x >= ( (win_sz.ws_row + scroll) - 7))
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
|
||||
} /* Print only arp request */
|
||||
@@ -292,10 +302,10 @@
|
||||
/* Get source IP */
|
||||
sprintf(tline, "%s ", arprep_l->sip);
|
||||
strcat(line, tline);
|
||||
-
|
||||
- /* Fill with spaces */
|
||||
- for (j=strlen(line); j<17; j++)
|
||||
- strcat(line, blank);
|
||||
+
|
||||
+ /* Fill with spaces */
|
||||
+ for (j=strlen(line); j<17; j++)
|
||||
+ strcat(line, blank);
|
||||
|
||||
/* Get source MAC */
|
||||
sprintf(tline, "%02x:%02x:%02x:%02x:%02x:%02x ",
|
||||
@@ -308,27 +318,29 @@
|
||||
sprintf(tline, "%s", arprep_l->dip);
|
||||
strcat(line, tline);
|
||||
|
||||
- /* Fill with spaces */
|
||||
- for (j=strlen(line); j<54; j++)
|
||||
- strcat(line, blank);
|
||||
+ /* Fill with spaces */
|
||||
+ for (j=strlen(line); j<54; j++)
|
||||
+ strcat(line, blank);
|
||||
|
||||
/* Count, Length & Vendor */
|
||||
sprintf(tline, "%02d", arprep_l->count);
|
||||
strcat(line, tline);
|
||||
|
||||
- /* Fill again with spaces */
|
||||
- for (j=strlen(line); j<win_sz.ws_col - 1; j++)
|
||||
- strcat(line, blank);
|
||||
+ /* Fill again with spaces */
|
||||
+ for (j=strlen(line); j<win_sz.ws_col - 1; j++)
|
||||
+ strcat(line, blank);
|
||||
|
||||
printf("%s\n", line);
|
||||
}
|
||||
|
||||
arprep_l = arprep_l->next;
|
||||
x += 1;
|
||||
-
|
||||
- /* Check if end of screen was reached */
|
||||
- if (x >= ( (win_sz.ws_row + scroll) - 7))
|
||||
- break;
|
||||
+
|
||||
+ if (!machine) {
|
||||
+ /* Check if end of screen was reached */
|
||||
+ if (x >= ( (win_sz.ws_row + scroll) - 7))
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
else if(smode == 2)
|
||||
diff -Naur netdiscover-0.3-beta6.orig/src/screen.h netdiscover-0.3-beta6/src/screen.h
|
||||
--- netdiscover-0.3-beta6.orig/src/screen.h 2009-06-24 18:21:11.000000000 -0400
|
||||
+++ netdiscover-0.3-beta6/src/screen.h 2009-06-24 21:42:13.000000000 -0400
|
||||
@@ -60,6 +60,7 @@
|
||||
char *vendor;
|
||||
short type;
|
||||
unsigned int count;
|
||||
+ int printed;
|
||||
struct arp_rep_l *next;
|
||||
};
|
||||
|
@ -1,34 +0,0 @@
|
||||
diff -Naur netdiscover-0.3-beta6.01machine/src/main.c netdiscover-0.3-beta6/src/main.c
|
||||
--- netdiscover-0.3-beta6.01machine/src/main.c 2009-06-25 18:19:18.000000000 -0400
|
||||
+++ netdiscover-0.3-beta6/src/main.c 2009-07-16 06:37:43.000000000 -0400
|
||||
@@ -121,6 +121,8 @@
|
||||
node = 67;
|
||||
pcount = 1;
|
||||
nokeywait = 0;
|
||||
+ fastmode = 0;
|
||||
+ ssleep = 0;
|
||||
|
||||
current_network = (char *) malloc ((sizeof(char)) * 16);
|
||||
sprintf(current_network,"Starting.");
|
||||
@@ -250,7 +252,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
-
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -299,9 +300,10 @@
|
||||
lnet_destroy();
|
||||
if (inject->scan_secs > 0) {
|
||||
sleep(inject->scan_secs);
|
||||
- pthread_kill(*(inject->sniffer), SIGKILL);
|
||||
- pthread_kill(*(inject->screen), SIGKILL);
|
||||
- pthread_kill(*(inject->keys), SIGKILL);
|
||||
+ pthread_kill(*(inject->sniffer), SIGTERM);
|
||||
+ pthread_kill(*(inject->screen), SIGTERM);
|
||||
+ pthread_kill(*(inject->keys), SIGTERM);
|
||||
+ sighandler(SIGTERM);
|
||||
}
|
||||
|
||||
return NULL;
|
Loading…
Reference in New Issue
Block a user