Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
masscan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
masscan
Commits
fbe1db2c
Commit
fbe1db2c
authored
7 years ago
by
Robert Graham
Browse files
Options
Downloads
Patches
Plain Diff
npcap support
parent
a71d2e51
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+1
-1
1 addition, 1 deletion
Makefile
src/rawsock-pcap.c
+13
-96
13 additions, 96 deletions
src/rawsock-pcap.c
src/rawsock-pcap.h
+0
-8
0 additions, 8 deletions
src/rawsock-pcap.h
src/rawsock.c
+8
-0
8 additions, 0 deletions
src/rawsock.c
with
22 additions
and
105 deletions
Makefile
+
1
−
1
View file @
fbe1db2c
...
...
@@ -66,7 +66,7 @@ FLAGS2 =
endif
# this works on llvm or real gcc
CC
=
gcc
CC
=
clang
DEFINES
=
CFLAGS
=
-g
-ggdb
$(
FLAGS2
)
$(
INCLUDES
)
$(
DEFINES
)
-Wall
-O3
...
...
This diff is collapsed.
Click to expand it.
src/rawsock-pcap.c
+
13
−
96
View file @
fbe1db2c
...
...
@@ -168,74 +168,10 @@ static const char *null_PCAP_LIB_VERSION(void)
return
"stub/0.0"
;
}
#ifdef WIN32
static
void
*
null_PCAP_GET_AIRPCAP_HANDLE
(
void
*
p
)
{
UNUSEDPARM
(
p
);
return
NULL
;
}
#endif
#ifdef WIN32
static
unsigned
null_AIRPCAP_SET_DEVICE_CHANNEL
(
void
*
p
,
unsigned
channel
)
{
UNUSEDPARM
(
p
);
UNUSEDPARM
(
channel
);
return
0
;
/*0=failure, 1=success*/
}
#endif
static
unsigned
null_CAN_TRANSMIT
(
const
char
*
devicename
)
{
#if WIN32
struct
DeviceCapabilities
{
unsigned
AdapterId
;
/* An Id that identifies the adapter model.*/
char
AdapterModelName
;
/* String containing a printable adapter model.*/
unsigned
AdapterBus
;
/* The type of bus the adapter is plugged to. */
unsigned
CanTransmit
;
/* TRUE if the adapter is able to perform frame injection.*/
unsigned
CanSetTransmitPower
;
/* TRUE if the adapter's transmit power is can be specified by the user application.*/
unsigned
ExternalAntennaPlug
;
/* TRUE if the adapter supports plugging one or more external antennas.*/
unsigned
SupportedMedia
;
unsigned
SupportedBands
;
}
caps
;
void
*
(
*
myopen
)(
const
char
*
devicename
,
char
*
errbuf
);
void
(
*
myclose
)(
void
*
h
);
unsigned
(
*
mycapabilities
)(
void
*
h
,
struct
DeviceCapabilities
*
caps
);
unsigned
result
=
0
;
void
*
hAirpcap
;
hAirpcap
=
LoadLibraryA
(
"airpcap.dll"
);
if
(
hAirpcap
==
NULL
)
return
0
;
myopen
=
(
void
*
(
*
)(
const
char
*
,
char
*
))
GetProcAddress
(
hAirpcap
,
"AirpcapOpen"
);
myclose
=
(
void
(
*
)(
void
*
))
GetProcAddress
(
hAirpcap
,
"AirpcapClose"
);
mycapabilities
=
(
unsigned
(
*
)(
void
*
,
struct
DeviceCapabilities
*
))
GetProcAddress
(
hAirpcap
,
"AirpcapGetDeviceCapabilities"
);
if
(
myopen
&&
mycapabilities
&&
myclose
)
{
void
*
h
=
myopen
(
devicename
,
NULL
);
if
(
h
)
{
if
(
mycapabilities
(
h
,
&
caps
))
{
result
=
caps
.
CanTransmit
;
}
myclose
(
h
);
}
}
FreeLibrary
(
hAirpcap
);
return
result
;
#elif defined(__linux__)
return
1
;
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
return
1
;
#else
#error unknown os
#endif
}
struct
PcapFunctions
PCAP
=
{
0
,
0
,
0
,
0
,
0
,
null_PCAP_CLOSE
,
...
...
@@ -345,40 +281,36 @@ int pcap_init(void)
#ifdef WIN32
void
*
hPacket
;
void
*
hLibpcap
;
void
*
hAirpcap
;
pl
->
is_available
=
0
;
pl
->
is_printing_debug
=
1
;
/* Look for the Packet.dll */
hPacket
=
LoadLibraryA
(
"NPcap
\\
Packet.dll"
);
if
(
hPacket
==
NULL
)
hPacket
=
LoadLibraryA
(
"Packet.dll"
);
if
(
hPacket
==
NULL
)
{
if
(
pl
->
is_printing_debug
)
switch
(
GetLastError
())
{
case
ERROR_MOD_NOT_FOUND
:
fprintf
(
stderr
,
"%s: not found
\n
"
,
"Packet.dll"
);
return
;
return
-
1
;
default:
fprintf
(
stderr
,
"%s: couldn't load %d
\n
"
,
"Packet.dll"
,
(
int
)
GetLastError
());
return
;
return
-
1
;
}
}
/* Look for the Packet.dll */
/* Look for the winpcap.dll */
hLibpcap
=
LoadLibraryA
(
"Npcap
\\
wpcap.dll"
);
if
(
hLibpcap
==
NULL
)
hLibpcap
=
LoadLibraryA
(
"wpcap.dll"
);
if
(
hLibpcap
==
NULL
)
{
if
(
pl
->
is_printing_debug
)
fprintf
(
stderr
,
"%s: couldn't load %d
\n
"
,
"wpcap.dll"
,
(
int
)
GetLastError
());
return
;
return
-
1
;
}
/* Look for the Packet.dll */
hAirpcap
=
LoadLibraryA
(
"airpcap.dll"
);
if
(
hLibpcap
==
NULL
)
{
if
(
pl
->
is_printing_debug
)
fprintf
(
stderr
,
"%s: couldn't load %d
\n
"
,
"airpcap.dll"
,
(
int
)
GetLastError
());
return
;
}
#define DOLINK(PCAP_DATALINK, datalink) \
pl->datalink = (PCAP_DATALINK)GetProcAddress(hLibpcap, "pcap_"#datalink); \
...
...
@@ -430,20 +362,6 @@ pl->func_err=0, pl->datalink = null_##PCAP_DATALINK;
#endif
#endif
#ifdef WIN32
DOLINK
(
PCAP_GET_AIRPCAP_HANDLE
,
get_airpcap_handle
);
if
(
pl
->
func_err
)
{
pl
->
func_err
=
0
;
}
if
(
hAirpcap
)
{
pl
->
airpcap_set_device_channel
=
(
AIRPCAP_SET_DEVICE_CHANNEL
)
GetProcAddress
(
hAirpcap
,
"AirpcapSetDeviceChannel"
);
if
(
pl
->
airpcap_set_device_channel
==
NULL
)
pl
->
airpcap_set_device_channel
=
null_AIRPCAP_SET_DEVICE_CHANNEL
;
}
#endif
DOLINK
(
PCAP_CLOSE
,
close
);
DOLINK
(
PCAP_DATALINK
,
datalink
);
DOLINK
(
PCAP_DISPATCH
,
dispatch
);
...
...
@@ -472,7 +390,6 @@ pl->func_err=0, pl->datalink = null_##PCAP_DATALINK;
DOLINK
(
PCAP_SENDQUEUE_QUEUE
,
sendqueue_queue
);
pl
->
can_transmit
=
null_CAN_TRANSMIT
;
if
(
!
pl
->
func_err
)
pl
->
is_available
=
1
;
...
...
This diff is collapsed.
Click to expand it.
src/rawsock-pcap.h
+
0
−
8
View file @
fbe1db2c
...
...
@@ -74,9 +74,6 @@ typedef int (*PCAP_MAJOR_VERSION)(void *p);
typedef
int
(
*
PCAP_MINOR_VERSION
)(
void
*
p
);
typedef
void
*
(
*
PCAP_OPEN_LIVE
)(
const
char
*
devicename
,
unsigned
snap_length
,
unsigned
is_promiscuous
,
unsigned
read_timeout
,
char
*
errbuf
);
typedef
void
(
*
PCAP_FREEALLDEVS
)(
pcap_if_t
*
alldevs
);
typedef
void
*
(
*
PCAP_GET_AIRPCAP_HANDLE
)(
void
*
p
);
typedef
unsigned
(
*
AIRPCAP_SET_DEVICE_CHANNEL
)(
void
*
p
,
unsigned
channel
);
typedef
unsigned
(
*
CAN_TRANSMIT
)(
const
char
*
devicename
);
typedef
pcap_t
*
(
*
PCAP_OPEN_OFFLINE
)(
const
char
*
fname
,
char
*
errbuf
);
typedef
int
(
*
PCAP_SENDPACKET
)(
pcap_t
*
p
,
const
unsigned
char
*
buf
,
int
size
);
typedef
const
unsigned
char
*
(
*
PCAP_NEXT
)(
pcap_t
*
p
,
struct
pcap_pkthdr
*
h
);
...
...
@@ -121,12 +118,7 @@ struct PcapFunctions {
PCAP_MAJOR_VERSION
major_version
;
PCAP_MINOR_VERSION
minor_version
;
PCAP_OPEN_LIVE
open_live
;
PCAP_GET_AIRPCAP_HANDLE
get_airpcap_handle
;
AIRPCAP_SET_DEVICE_CHANNEL
airpcap_set_device_channel
;
//AIRPCAP_SET_FCS_PRESENCE airpcap_set_fcs_presence;
//BOOL AirpcapSetFcsPresence(PAirpcapHandle AdapterHandle, BOOL IsFcsPresent);
CAN_TRANSMIT
can_transmit
;
PCAP_OPEN_OFFLINE
open_offline
;
PCAP_SENDPACKET
sendpacket
;
...
...
This diff is collapsed.
Click to expand it.
src/rawsock.c
+
8
−
0
View file @
fbe1db2c
...
...
@@ -485,6 +485,14 @@ rawsock_ignore_transmits(struct Adapter *adapter, const unsigned char *adapter_m
return
;
}
if
(
adapter
->
pcap
)
{
int
err
;
err
=
PCAP
.
setdirection
(
adapter
->
pcap
,
PCAP_D_IN
);
if
(
err
)
{
PCAP
.
perror
(
adapter
->
pcap
,
"pcap_setdirection(IN)"
);
}
}
#if !defined(WIN32)
/* PORTABILITY: this is what we do on all systems except windows, because
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment