Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable [--arp] output mac addr to xml #305

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/out-binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ binary_out_close(struct Output *out, FILE *fp)
****************************************************************************/
static void
binary_out_status(struct Output *out, FILE *fp, time_t timestamp,
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6])
{
unsigned char foo[256];
size_t bytes_written;
Expand Down
2 changes: 1 addition & 1 deletion src/out-certs.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cert_out_close(struct Output *out, FILE *fp)
******************************************************************************/
static void
cert_out_status(struct Output *out, FILE *fp, time_t timestamp, int status,
unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6])
{
/* certificates only come with banner info, so there is no port info
* to report */
Expand Down
2 changes: 1 addition & 1 deletion src/out-grepable.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ grepable_out_close(struct Output *out, FILE *fp)
****************************************************************************/
static void
grepable_out_status(struct Output *out, FILE *fp, time_t timestamp,
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6])
{
UNUSEDPARM(timestamp);
UNUSEDPARM(out);
Expand Down
2 changes: 1 addition & 1 deletion src/out-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ json_out_close(struct Output *out, FILE *fp)
****************************************************************************/
static void
json_out_status(struct Output *out, FILE *fp, time_t timestamp, int status,
unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6])
{
char reason_buffer[128];
UNUSEDPARM(out);
Expand Down
2 changes: 1 addition & 1 deletion src/out-null.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ null_out_close(struct Output *out, FILE *fp)
****************************************************************************/
static void
null_out_status(struct Output *out, FILE *fp, time_t timestamp,
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6])
{
UNUSEDPARM(timestamp);
UNUSEDPARM(out);
Expand Down
2 changes: 1 addition & 1 deletion src/out-redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ redis_out_close(struct Output *out, FILE *fp)
****************************************************************************/
static void
redis_out_status(struct Output *out, FILE *fp, time_t timestamp,
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6])
{
ptrdiff_t fd = (ptrdiff_t)fp;
char line[1024];
Expand Down
2 changes: 1 addition & 1 deletion src/out-text.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ text_out_close(struct Output *out, FILE *fp)
****************************************************************************/
static void
text_out_status(struct Output *out, FILE *fp, time_t timestamp,
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6])
{
UNUSEDPARM(ttl);
UNUSEDPARM(reason);
Expand Down
2 changes: 1 addition & 1 deletion src/out-unicornscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ unicornscan_out_close(struct Output *out, FILE *fp)

static void
unicornscan_out_status(struct Output *out, FILE *fp, time_t timestamp,
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6])
{
UNUSEDPARM(reason);
UNUSEDPARM(out);
Expand Down
70 changes: 49 additions & 21 deletions src/out-xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,58 @@ xml_out_close(struct Output *out, FILE *fp)
****************************************************************************/
static void
xml_out_status(struct Output *out, FILE *fp, time_t timestamp, int status,
unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl)
unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6])
{
char reason_buffer[128];
UNUSEDPARM(out);
fprintf(fp, "<host endtime=\"%u\">"
"<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>"
"<ports>"
"<port protocol=\"%s\" portid=\"%u\">"
"<state state=\"%s\" reason=\"%s\" reason_ttl=\"%u\"/>"
"</port>"
"</ports>"
"</host>"
"\r\n",
(unsigned)timestamp,
(ip>>24)&0xFF,
(ip>>16)&0xFF,
(ip>> 8)&0xFF,
(ip>> 0)&0xFF,
name_from_ip_proto(ip_proto),
port,
status_string(status),
reason_string(reason, reason_buffer, sizeof(reason_buffer)),
ttl
);

switch (ip_proto) {
case 0: /* ARP */
fprintf(fp, "<host endtime=\"%u\">"
"<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>"
"<ports>"
"<port protocol=\"%s\" portid=\"%u\">"
"<state state=\"%s\" reason=\"%s\" reason_ttl=\"%u\"/>"
"</port>"
"</ports>"
"<mac addr=\"%02x:%02x:%02x:%02x:%02x:%02x\">"
"</host>"
"\r\n",
(unsigned)timestamp,
(ip>>24)&0xFF,
(ip>>16)&0xFF,
(ip>> 8)&0xFF,
(ip>> 0)&0xFF,
name_from_ip_proto(ip_proto),
port,
status_string(status),
reason_string(reason, reason_buffer, sizeof(reason_buffer)),
ttl,
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
);
break;
default:
fprintf(fp, "<host endtime=\"%u\">"
"<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>"
"<ports>"
"<port protocol=\"%s\" portid=\"%u\">"
"<state state=\"%s\" reason=\"%s\" reason_ttl=\"%u\"/>"
"</port>"
"</ports>"
"</host>"
"\r\n",
(unsigned)timestamp,
(ip>>24)&0xFF,
(ip>>16)&0xFF,
(ip>> 8)&0xFF,
(ip>> 0)&0xFF,
name_from_ip_proto(ip_proto),
port,
status_string(status),
reason_string(reason, reason_buffer, sizeof(reason_buffer)),
ttl
);
}
}

/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ output_report_status(struct Output *out, time_t timestamp, int status,
* Now do the actual output, whether it be XML, binary, JSON, Redis,
* and so on.
*/
out->funcs->status(out, fp, timestamp, status, ip, ip_proto, port, reason, ttl);
out->funcs->status(out, fp, timestamp, status, ip, ip_proto, port, reason, ttl, mac);
}


Expand Down
2 changes: 1 addition & 1 deletion src/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct OutputType {
void (*status)(struct Output *out, FILE *fp,
time_t timestamp, int status,
unsigned ip, unsigned ip_proto, unsigned port,
unsigned reason, unsigned ttl);
unsigned reason, unsigned ttl, const unsigned char mac[6]);
void (*banner)(struct Output *out, FILE *fp,
time_t timestamp, unsigned ip, unsigned ip_proto,
unsigned port, enum ApplicationProtocol proto,
Expand Down