[
  {
    "path": ".gitignore",
    "content": "Release*\n*.exe\n\n# OS X\n.DS_Store\n\n# Xcode\nbuild/\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mode2v3\n*.perspectivev3\n!default.perspectivev3\nxcuserdata\n*.xccheckout\nprofile\n*.moved-aside\nDerivedData\n*.hmap\n*.xccheckout\n\n# CocoaPods\nPods\n\n# iOSOpenDev\nPackages\nLatestBuild\n\n"
  },
  {
    "path": "README.md",
    "content": "arp-scan\n====\n\n[![Security Status](https://s.murphysec.com/badge/QbsuranAlang/arp-scan-windows-.svg)](https://www.murphysec.com/p/QbsuranAlang/arp-scan-windows-)\n\narp-scan is for windows only, support x86 and x64.\n\nOption\n-----\n* -t: target, format: [IP/slash] or [IP]\n\nUsage\n-----\n```\narp-scan -t IP/slash\narp-scan -t IP\n```\n\nExample\n-----\n```\narp-scan -t 192.168.1.1/24\narp-scan -t 172.20.10.1\n```\n"
  },
  {
    "path": "arp-scan/arp-scan/arp-scan.c",
    "content": "#include <WinSock2.h>\r\n#include <iphlpapi.h>\r\n#include <stdio.h>\r\n#include <stdbool.h>\r\n#include \"getopt.h\"\r\n//link to librarys\r\n#pragma comment(lib, \"Ws2_32.lib\")\r\n#pragma comment(lib, \"iphlpapi.lib\")\r\n\r\nstatic void usage(char *cmd) {\r\n\tfprintf(stderr, \"Usage: %s -t [IP/slash] or [IP]\\n\", cmd);\r\n\texit(1);\r\n}//end usage\r\n\r\nstatic void controlc() {\r\n\tprintf(\"Enter Ctrl-C to Abort. Please waiting...\\n\");\r\n\tWSACleanup();\r\n\texit(0);\r\n}//end controlc\r\n\r\nstatic u_long lookupAddress(const char* pcHost) {\r\n\tstruct in_addr address;\r\n\tstruct hostent *pHE = NULL;\r\n\tu_long nRemoteAddr;\r\n\tbool was_a_name = false;\r\n\r\n\tnRemoteAddr = inet_addr(pcHost);\r\n\r\n\tif (nRemoteAddr == INADDR_NONE) {\r\n\t\t// pcHost isn't a dotted IP, so resolve it through DNS\r\n\t\tpHE = gethostbyname(pcHost);\r\n\r\n\t\tif (pHE == 0) {\r\n\t\t\treturn INADDR_NONE;\r\n\t\t}//end if\r\n\t\tnRemoteAddr = *((u_long*)pHE->h_addr_list[0]);\r\n\t\twas_a_name = true;\r\n\t}\r\n\tif (was_a_name) {\r\n\t\tmemcpy(&address, &nRemoteAddr, sizeof(u_long));\r\n\t\tprintf(\"DNS: %s, is %s\\n\", pcHost, inet_ntoa(address));\r\n\t}//end if\r\n\treturn nRemoteAddr;\r\n}//end lookupAddress\r\n\r\nstatic DWORD WINAPI sendAnARP(LPVOID lpArg) {\r\n\tu_long DestIp = *(int *)lpArg;\r\n\r\n\tIPAddr SrcIp = 0;       /* default for src ip */\r\n\tULONG MacAddr[2];       /* for 6-byte hardware addresses */\r\n\tULONG PhysAddrLen = 6;  /* default to length of six bytes */\r\n\tBYTE *bPhysAddr;\r\n\tDWORD dwRetVal;\r\n\t//get reply time\r\n\tLARGE_INTEGER response_timer1;\r\n\tLARGE_INTEGER response_timer2;\r\n\tLARGE_INTEGER cpu_frequency;\r\n\tdouble response_time;\r\n\r\n\tmemset(&MacAddr, 0xff, sizeof(MacAddr));\r\n\tPhysAddrLen = 6;\r\n\r\n\tSetThreadAffinityMask(GetCurrentThread(), 1);\r\n\tQueryPerformanceFrequency((LARGE_INTEGER *)&cpu_frequency);\r\n\r\n\t//sned arp and wait for reply\r\n\tQueryPerformanceCounter((LARGE_INTEGER *)&response_timer1);\r\n\tdwRetVal = SendARP(DestIp, SrcIp, &MacAddr, &PhysAddrLen);\r\n\tQueryPerformanceCounter((LARGE_INTEGER *)&response_timer2);\r\n\r\n\tresponse_time = ((double)((response_timer2.QuadPart - response_timer1.QuadPart) * (double) 1000.0 / (double)cpu_frequency.QuadPart));\r\n\r\n\t//output\r\n\tbPhysAddr = (BYTE *)& MacAddr;\r\n\r\n\tif (PhysAddrLen) {\r\n\t\tchar message[256];\r\n\t\tint i;\r\n\t\tmemset(message, 0, sizeof(message));\r\n\t\tsprintf(message, \"Reply that \");\r\n\r\n\t\tfor (i = 0; i < (int)PhysAddrLen; i++) {\r\n\t\t\tif (i == (PhysAddrLen - 1))\r\n\t\t\t\tsprintf(message, \"%s%.2X\", message, (int)bPhysAddr[i]);\r\n\t\t\telse\r\n\t\t\t\tsprintf(message, \"%s%.2X:\", message, (int)bPhysAddr[i]);\r\n\t\t}//end for\r\n\r\n\t\tstruct in_addr ip_addr;\r\n\t\tip_addr.s_addr = DestIp;\r\n\t\tsprintf(message, \"%s is %s in %f\", message, inet_ntoa(ip_addr), response_time);\r\n\t\tprintf(\"%s\\n\", message);\r\n\t}//end if\r\n\treturn 0;\r\n}//end sendAnARP\r\n\r\nstatic u_long getFirstIP(u_long Ip, u_char slash) {\r\n\tIPAddr newDestIp = 0;\r\n\tint i;\r\n\tIPAddr oldDestIp = ntohl(Ip);\r\n\tu_long mask = 1 << (32 - slash);\r\n\tfor (i = 0; i < slash; i++) {\r\n\t\tnewDestIp += oldDestIp & mask;\r\n\t\tmask <<= 1;\r\n\t}//end for\r\n\t//skip network IP\r\n\treturn ntohl(++newDestIp);\r\n}//end getFirstIP\r\n\r\n#define WSA_VERSION MAKEWORD(2, 2) // using winsock 2.2\r\nstatic bool init_winsock() {\r\n\tWSADATA\tWSAData = { 0 };\r\n\tif (WSAStartup(WSA_VERSION, &WSAData) != 0) {\r\n\t\t// Tell the user that we could not find a usable WinSock DLL.\r\n\t\tif (LOBYTE(WSAData.wVersion) != LOBYTE(WSA_VERSION) ||\r\n\t\t\tHIBYTE(WSAData.wVersion) != HIBYTE(WSA_VERSION)) {\r\n\t\t\tfprintf(stderr, \"WSAStartup(): Incorrect winsock version\\n\");\r\n\t\t}//end if\r\n\t\tWSACleanup();\r\n\t\treturn false;\r\n\t}//end if\r\n\treturn true;\r\n}//end init_winsock\r\n\r\nint main(int argc, char *argv[]) {\r\n\tchar *destIpStr = NULL;\r\n\tu_char slash = 32;\r\n\tint c;\r\n\tIPAddr destIp = 0;\r\n\tu_long loopcount;\r\n\tHANDLE *hHandles;\r\n\tDWORD ThreadId;\r\n\tu_long i = 0;\r\n\r\n\twhile ((c = getopt(argc, argv, \"t:\")) != EOF) {\r\n\t\tswitch (c) {\r\n\t\tcase 't':\r\n\t\t\tdestIpStr = optarg;\r\n\t\t\tbreak;\r\n\t\tdefault:\r\n\t\t\tusage(argv[0]);\r\n\t\t}//end while\r\n\t}//end while to read option\r\n\r\n\tif (!destIpStr) {\r\n\t\tusage(argv[0]);\r\n\t}//end if usage\r\n\r\n\tif (!init_winsock()) {\r\n\t\texit(1);\r\n\t}//end if\r\n\r\n\t//get arugment\r\n\tstrtok(destIpStr, \"//\");\r\n\tchar *slash_str = strtok(NULL, \"\");\r\n\tif (slash_str) {\r\n\t\tslash = atoi(slash_str);\r\n\t}//end if\r\n\r\n\t//translate to ulong\r\n\tdestIp = lookupAddress(destIpStr);\r\n\r\n\t//move to first IP\r\n\tif (slash != 32) {\r\n\t\tdestIp = getFirstIP(destIp, slash);\r\n\t}//end if\r\n\r\n\tif (destIp == INADDR_NONE) {\r\n\t\tfprintf(stderr, \"Error: could not determine IP address for %s\\n\", destIpStr);\r\n\t\texit(1);\r\n\t}//end if\r\n\r\n\t//set control-c handler\r\n\tSetConsoleCtrlHandler((PHANDLER_ROUTINE)&controlc, TRUE);\r\n\r\n\tloopcount = 1 << (32 - slash);\r\n\thHandles = (HANDLE *)malloc(sizeof(HANDLE) * loopcount);\r\n\r\n\t//inject\r\n\tfor (i = 0; i < loopcount; i++) {\r\n\t\tstruct in_addr ip_addr;\r\n\t\tip_addr.s_addr = destIp;\r\n\r\n\t\thHandles[i] = CreateThread(NULL, 0, sendAnARP, &destIp, 0, &ThreadId);\r\n\r\n\t\tif (hHandles[i] == NULL) {\r\n\t\t\tfprintf(stderr, \"Could not create Thread.\\n\");\r\n\t\t\texit(1);\r\n\t\t}//end if\r\n\r\n\t\tSleep(10);\r\n\t\tu_long temp = ntohl(destIp);\r\n\t\tdestIp = ntohl(++temp);\r\n\t}//end for\r\n\r\n\tfor (i = 0; i < loopcount; i++) {\r\n\t\tWaitForSingleObject(hHandles[i], INFINITE);\r\n\t}//end for\r\n\r\n\tWSACleanup();\r\n\r\n\texit(0);\r\n}//end main"
  },
  {
    "path": "arp-scan/arp-scan/getopt.c",
    "content": "/*****************************************************************************\n* getopt.c - competent and free getopt library.\n* $Header: /cvsroot/freegetopt/freegetopt/getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $\n*\n* Copyright (c)2002-2003 Mark K. Kim\n* All rights reserved.\n* \n* Redistribution and use in source and binary forms, with or without\n* modification, are permitted provided that the following conditions\n* are met:\n*\n*   * Redistributions of source code must retain the above copyright\n*     notice, this list of conditions and the following disclaimer.\n*\n*   * Redistributions in binary form must reproduce the above copyright\n*     notice, this list of conditions and the following disclaimer in\n*     the documentation and/or other materials provided with the\n*     distribution.\n*\n*   * Neither the original author of this software nor the names of its\n*     contributors may be used to endorse or promote products derived\n*     from this software without specific prior written permission.\n*\n* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\n* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\n* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS\n* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\n* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF\n* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\n* DAMAGE.\n*/\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include \"getopt.h\"\n\n\nstatic const char* ID = \"$Id: getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $\";\n\n\nchar* optarg = NULL;\nint optind = 0;\nint opterr = 1;\nint optopt = '?';\n\n\nstatic char** prev_argv = NULL;        /* Keep a copy of argv and argc to */\nstatic int prev_argc = 0;              /*    tell if getopt params change */\nstatic int argv_index = 0;             /* Option we're checking */\nstatic int argv_index2 = 0;            /* Option argument we're checking */\nstatic int opt_offset = 0;             /* Index into compounded \"-option\" */\nstatic int dashdash = 0;               /* True if \"--\" option reached */\nstatic int nonopt = 0;                 /* How many nonopts we've found */\n\nstatic void increment_index()\n{\n\t/* Move onto the next option */\n\tif(argv_index < argv_index2)\n\t{\n\t\twhile(prev_argv[++argv_index] && prev_argv[argv_index][0] != '-'\n\t\t\t\t&& argv_index < argv_index2+1);\n\t}\n\telse argv_index++;\n\topt_offset = 1;\n}\n\n\n/*\n* Permutes argv[] so that the argument currently being processed is moved\n* to the end.\n*/\nstatic int permute_argv_once()\n{\n\t/* Movability check */\n\tif(argv_index + nonopt >= prev_argc) return 1;\n\t/* Move the current option to the end, bring the others to front */\n\telse\n\t{\n\t\tchar* tmp = prev_argv[argv_index];\n\n\t\t/* Move the data */\n\t\tmemmove(&prev_argv[argv_index], &prev_argv[argv_index+1],\n\t\t\t\tsizeof(char**) * (prev_argc - argv_index - 1));\n\t\tprev_argv[prev_argc - 1] = tmp;\n\n\t\tnonopt++;\n\t\treturn 0;\n\t}\n}\n\n\nint getopt(int argc, char** argv, char* optstr)\n{\n\tint c = 0;\n\n\t/* If we have new argv, reinitialize */\n\tif(prev_argv != argv || prev_argc != argc)\n\t{\n\t\t/* Initialize variables */\n\t\tprev_argv = argv;\n\t\tprev_argc = argc;\n\t\targv_index = 1;\n\t\targv_index2 = 1;\n\t\topt_offset = 1;\n\t\tdashdash = 0;\n\t\tnonopt = 0;\n\t}\n\n\t/* Jump point in case we want to ignore the current argv_index */\n\tgetopt_top:\n\n\t/* Misc. initializations */\n\toptarg = NULL;\n\n\t/* Dash-dash check */\n\tif(argv[argv_index] && !strcmp(argv[argv_index], \"--\"))\n\t{\n\t\tdashdash = 1;\n\t\tincrement_index();\n\t}\n\n\t/* If we're at the end of argv, that's it. */\n\tif(argv[argv_index] == NULL)\n\t{\n\t\tc = -1;\n\t}\n\t/* Are we looking at a string? Single dash is also a string */\n\telse if(dashdash || argv[argv_index][0] != '-' || !strcmp(argv[argv_index], \"-\"))\n\t{\n\t\t/* If we want a string... */\n\t\tif(optstr[0] == '-')\n\t\t{\n\t\t\tc = 1;\n\t\t\toptarg = argv[argv_index];\n\t\t\tincrement_index();\n\t\t}\n\t\t/* If we really don't want it (we're in POSIX mode), we're done */\n\t\telse if(optstr[0] == '+' || getenv(\"POSIXLY_CORRECT\"))\n\t\t{\n\t\t\tc = -1;\n\n\t\t\t/* Everything else is a non-opt argument */\n\t\t\tnonopt = argc - argv_index;\n\t\t}\n\t\t/* If we mildly don't want it, then move it back */\n\t\telse\n\t\t{\n\t\t\tif(!permute_argv_once()) goto getopt_top;\n\t\t\telse c = -1;\n\t\t}\n\t}\n\t/* Otherwise we're looking at an option */\n\telse\n\t{\n\t\tchar* opt_ptr = NULL;\n\n\t\t/* Grab the option */\n\t\tc = argv[argv_index][opt_offset++];\n\n\t\t/* Is the option in the optstr? */\n\t\tif(optstr[0] == '-') opt_ptr = strchr(optstr+1, c);\n\t\telse opt_ptr = strchr(optstr, c);\n\t\t/* Invalid argument */\n\t\tif(!opt_ptr)\n\t\t{\n\t\t\tif(opterr)\n\t\t\t{\n\t\t\t\tfprintf(stderr, \"%s: invalid option -- %c\\n\", argv[0], c);\n\t\t\t}\n\n\t\t\toptopt = c;\n\t\t\tc = '?';\n\n\t\t\t/* Move onto the next option */\n\t\t\tincrement_index();\n\t\t}\n\t\t/* Option takes argument */\n\t\telse if(opt_ptr[1] == ':')\n\t\t{\n\t\t\t/* ie, -oARGUMENT, -xxxoARGUMENT, etc. */\n\t\t\tif(argv[argv_index][opt_offset] != '\\0')\n\t\t\t{\n\t\t\t\toptarg = &argv[argv_index][opt_offset];\n\t\t\t\tincrement_index();\n\t\t\t}\n\t\t\t/* ie, -o ARGUMENT (only if it's a required argument) */\n\t\t\telse if(opt_ptr[2] != ':')\n\t\t\t{\n\t\t\t\t/* One of those \"you're not expected to understand this\" moment */\n\t\t\t\tif(argv_index2 < argv_index) argv_index2 = argv_index;\n\t\t\t\twhile(argv[++argv_index2] && argv[argv_index2][0] == '-');\n\t\t\t\toptarg = argv[argv_index2];\n\n\t\t\t\t/* Don't cross into the non-option argument list */\n\t\t\t\tif(argv_index2 + nonopt >= prev_argc) optarg = NULL;\n\n\t\t\t\t/* Move onto the next option */\n\t\t\t\tincrement_index();\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t/* Move onto the next option */\n\t\t\t\tincrement_index();\n\t\t\t}\n\n\t\t\t/* In case we got no argument for an option with required argument */\n\t\t\tif(optarg == NULL && opt_ptr[2] != ':')\n\t\t\t{\n\t\t\t\toptopt = c;\n\t\t\t\tc = '?';\n\n\t\t\t\tif(opterr)\n\t\t\t\t{\n\t\t\t\t\tfprintf(stderr,\"%s: option requires an argument -- %c\\n\",\n\t\t\t\t\t\t\targv[0], optopt);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t/* Option does not take argument */\n\t\telse\n\t\t{\n\t\t\t/* Next argv_index */\n\t\t\tif(argv[argv_index][opt_offset] == '\\0')\n\t\t\t{\n\t\t\t\tincrement_index();\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Calculate optind */\n\tif(c == -1)\n\t{\n\t\toptind = argc - nonopt;\n\t}\n\telse\n\t{\n\t\toptind = argv_index;\n\t}\n\n\treturn c;\n}\n\n\n/* vim:ts=3\n*/\n"
  },
  {
    "path": "arp-scan/arp-scan/getopt.h",
    "content": "/*****************************************************************************\n* getopt.h - competent and free getopt library.\n* $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $\n*\n* Copyright (c)2002-2003 Mark K. Kim\n* All rights reserved.\n* \n* Redistribution and use in source and binary forms, with or without\n* modification, are permitted provided that the following conditions\n* are met:\n*\n*   * Redistributions of source code must retain the above copyright\n*     notice, this list of conditions and the following disclaimer.\n*\n*   * Redistributions in binary form must reproduce the above copyright\n*     notice, this list of conditions and the following disclaimer in\n*     the documentation and/or other materials provided with the\n*     distribution.\n*\n*   * Neither the original author of this software nor the names of its\n*     contributors may be used to endorse or promote products derived\n*     from this software without specific prior written permission.\n*\n* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n* \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\n* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\n* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\n* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS\n* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\n* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF\n* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH\n* DAMAGE.\n*/\n#ifndef GETOPT_H_\n#define GETOPT_H_\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\nextern char* optarg;\nextern int optind;\nextern int opterr;\nextern int optopt;\n\nint getopt(int argc, char** argv, char* optstr);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n\n#endif /* GETOPT_H_ */\n\n\n/* vim:ts=3\n*/\n"
  },
  {
    "path": "arp-scan/msvcbuild.bat",
    "content": "@rem compile arp-scan tool for x86 and x64\r\n\r\n@echo off\r\n@set COMPILE=cl /nologo /MT /O2 /W3 /D_CRT_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS /I arp-scan arp-scan/arp-scan.c arp-scan/getopt.c\r\n\r\n@rem compile x86\r\nrmdir /s /q Release(x86)\r\nmkdir Release(x86)\r\ncall \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x86\r\n%COMPILE%\r\ndel /q *.obj *.exp\r\nxcopy /Y arp-scan.exe Release(x86)\\\r\n\r\n@rem compile amd64\r\nrmdir /s /q Release(x64)\r\nmkdir Release(x64)\r\ncall \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat\" x64\r\n%COMPILE%\r\ndel /q *.obj *.exp\r\nxcopy /Y arp-scan.exe Release(x64)\\\r\n\r\ndel /q arp-scan.exe\r\n\r\necho Done!\r\nexit /b %errorlevel%"
  }
]