Skip to content

Instantly share code, notes, and snippets.

View dmiller-nmap's full-sized avatar

Daniel Miller dmiller-nmap

View GitHub Profile
@dmiller-nmap
dmiller-nmap / nmap-check.sh
Last active April 11, 2024 16:19 — forked from bonsaiviking/nmap-check.sh
Check for bugs and code quality issues in Nmap source files.
#!/bin/bash
PEP8=$(which pep8)
PEP8IGNORE=E123,E124,E126,E127,E128
if [ -z $PEP8 ]; then
echo "No pep8 in your path. Skipping Python checks"
else
for file in $(find "$@" -name '*.py'); do
OUTPUT=$(mktemp)
@dmiller-nmap
dmiller-nmap / pre-commit
Last active April 11, 2024 16:13 — forked from bonsaiviking/pre-commit
Pre-commit git hook for Nmap (WIP)
#!/bin/bash
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
if git rev-parse --verify HEAD >/dev/null 2>&1
then
@dmiller-nmap
dmiller-nmap / ssh-banner-nse.patch
Last active August 27, 2021 15:39
SSH banner grab NSE
diff --git a/libssh2/include/libssh2.h b/libssh2/include/libssh2.h
index d33df03..f649c50 100644
--- a/libssh2/include/libssh2.h
+++ b/libssh2/include/libssh2.h
@@ -611,6 +611,8 @@ LIBSSH2_API const char *libssh2_session_banner_get(LIBSSH2_SESSION *session);
LIBSSH2_API char *libssh2_userauth_list(LIBSSH2_SESSION *session,
const char *username,
unsigned int username_len);
+LIBSSH2_API char *libssh2_userauth_banner(LIBSSH2_SESSION * session,
+ size_t *banner_len_out);
diff --git a/packetWin7/npf/npf/ioctls.h b/packetWin7/npf/npf/ioctls.h
index d798cf6..fe3492f 100644
--- a/packetWin7/npf/npf/ioctls.h
+++ b/packetWin7/npf/npf/ioctls.h
@@ -100,7 +100,8 @@
and resets all the parameters associated with the buffer in the OPEN_INSTANCE structure. The currently
buffered packets are lost.
*/
-#define BIOCSETBUFFERSIZE 9592
+#define W_BIOCSETBUFFERSIZE 9592
@dmiller-nmap
dmiller-nmap / nmap-sanitize.py
Created September 6, 2018 16:53
Sanitizer for Nmap XML output - strips everything but port scan info and anonymizes IP addresses.
#!/usr/bin/env python2
import struct
import xml
xml.__path__ = [x for x in xml.__path__ if "_xmlplus" not in x]
import xml.sax
import xml.sax.saxutils
class NmapSanitizer(xml.sax.saxutils.XMLGenerator, object):
local ipOps = require "ipOps"
local nmap = require "nmap"
local packet = require "packet"
local stdnse = require "stdnse"
local string = require "string"
local target = require "target"
description = [[
Discovers Sonicwall firewalls which are directly attached (not routed) using
the same method as the manufacturers own 'SetupTool'. An interface needs to be
---Implements the HTTP client protocol in a standard form that Nmap scripts can
-- take advantage of.
--
-- Because HTTP has so many uses, there are a number of interfaces to this library.
-- The most obvious and common ones are simply <code>get</code>, <code>post</code>,
-- and <code>head</code>; or, if more control is required, <code>generic_request</code>
-- can be used. These functions do what one would expect. The <code>get_url</code>
-- helper function can be used to parse and retrieve a full URL.
--
-- HTTPS support is transparent. The library uses <code>comm.tryssl</code> to
@dmiller-nmap
dmiller-nmap / format.lua
Created July 31, 2015 18:30
WIP Formatting library for NSE
---
-- Formatting functions for script output
--
local stdnse = require "stdnse"
local table = require "table"
local string = require "string"
local debug = require "debug"
local _R = debug.getregistry()
_ENV = stdnse.module("format", stdnse.seeall)
@dmiller-nmap
dmiller-nmap / icmpid.patch
Created June 6, 2015 21:13
Patch to potentially solve nmap/nmap#154
diff --git a/scan_engine_raw.cc b/scan_engine_raw.cc
index 6d4b59a..40e0a2e 100644
--- a/scan_engine_raw.cc
+++ b/scan_engine_raw.cc
@@ -652,7 +652,8 @@ int get_ping_pcap_result(UltraScanInfo *USI, struct timeval *stime) {
sockaddr_storage_cmp(&target_src, &hdr.dst) != 0 ||
sockaddr_storage_cmp(&target_src, &encaps_hdr.src) != 0 ||
sockaddr_storage_cmp(&target_dst, &encaps_hdr.dst) != 0 ||
- ntohs(ping->id) != probe->icmpid())
+ ((probe->protocol() == IPPROTO_ICMP || probe->protocol() == IPPROTO_ICMPV6) &&
@dmiller-nmap
dmiller-nmap / http-vuln-cve2015-1427.nse
Created March 13, 2015 19:17
WIP NSE script to detect cve-2015-1427
local http = require "http"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local vulns = require "vulns"
local json = require "json"
local base64 = require "base64"
description = [[
A simple script based on the exploit mentioned here :