├── .gitignore ├── LICENSE ├── README.md ├── cmd └── np │ └── np.go ├── go.mod ├── go.sum ├── internal ├── result │ ├── print.go │ ├── result.go │ └── util.go ├── runner │ ├── options.go │ └── runner.go └── scan │ ├── dnsx │ └── dnsx.go │ ├── naabu │ └── naabu.go │ ├── nmap │ └── nmap.go │ ├── np.go │ └── scan.go └── testdata ├── 123_udp_version.xml ├── 80_443.xml ├── 80_443_version.xml ├── default_by_ip.xml ├── default_by_name_version_script.xml ├── masscan.xml ├── multi_host_80_443.xml ├── naabu-all-top-25.json ├── naabu-v2-all-top-100.json ├── notxml.txt ├── np.json ├── sub-ips-fast.xml ├── subdomain-ips.txt ├── subdomains.txt ├── subs-dnsx.json └── targets.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 14 | # Dependency directories (remove the comment below to include it) 15 | # vendor/ 16 | cmd/np/np 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # np 2 | 3 | np is a tool for parsing, combining, deduplicating, and querying the output from multiple different tools. 4 | 5 | Supported scan types: 6 | 7 | - Nmap XML output 8 | - Masscan XML output 9 | - Naabu JSON output 10 | - DNSx JSON output 11 | - `np` JSON output 12 | 13 | ## Usage 14 | 15 | ```text 16 | Usage of ./np: 17 | -debug 18 | Display debug output 19 | -exclude string 20 | Exclude these hosts from output 21 | -host string 22 | Show results for specified host 23 | -hosts 24 | Print alive hosts 25 | -json 26 | Display JSON output 27 | -path string 28 | Path to scan file (default ".") 29 | -port string 30 | Display hosts with matching port(s) 31 | -ports 32 | Print all ports 33 | -service string 34 | Display hosts with matching service name 35 | -services 36 | Print all services 37 | ``` 38 | 39 | The `-json` option will display all hosts with no filtering. Other formats omit ports that are likely false positives (e.g. `tcpwrapped`). 40 | 41 | ## Examples 42 | 43 | Parse all scans in the current directory: 44 | 45 | ```sh 46 | $ np 47 | scanme.nmap.org (45.33.32.156) 48 | PORT SERVICE PRODUCT VERSION 49 | 80/tcp http Apache httpd 2.4.7 50 | 22/tcp ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 51 | 9929/tcp nping-echo Nping echo 52 | 31337/tcp Elite 53 | 54 | bishopfox.com (159.223.119.162) 55 | PORT SERVICE PRODUCT VERSION 56 | 80/tcp http 57 | 443/tcp https 58 | ``` 59 | 60 | Parse all scans, but ignore a host: 61 | 62 | ```sh 63 | $ np -exclude bishopfox.com 64 | scanme.nmap.org (45.33.32.156) 65 | PORT SERVICE PRODUCT VERSION 66 | 80/tcp http Apache httpd 2.4.7 67 | 22/tcp ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 68 | 9929/tcp nping-echo Nping echo 69 | 31337/tcp Elite 70 | ``` 71 | 72 | Print a specific host: 73 | 74 | ```sh 75 | $ np -host scanme.nmap.org 76 | scanme.nmap.org (45.33.32.156) 77 | PORT SERVICE PRODUCT VERSION 78 | 80/tcp http Apache httpd 2.4.7 79 | 22/tcp ssh OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.13 80 | 9929/tcp nping-echo Nping echo 81 | 31337/tcp Elite 82 | ``` 83 | 84 | Print all alive hosts: 85 | 86 | ```sh 87 | $ np -hosts [-path /path/to/scans] 88 | scanme.nmap.org (45.33.32.156) 89 | bishopfox.com (159.223.119.162) 90 | ``` 91 | 92 | Print all services: 93 | 94 | ```sh 95 | $ np -services [-path /path/to/scans] 96 | scanme.nmap.org:9929 nping-echo 97 | scanme.nmap.org:31337 Elite 98 | scanme.nmap.org:22 ssh 99 | scanme.nmap.org:80 http 100 | bishopfox.com:80 http 101 | bishopfox.com:443 https 102 | ``` 103 | 104 | Show instances of the given service: 105 | 106 | ```sh 107 | $ np -service https [-path /path/to/scans] 108 | bishopfox.com:443 109 | ``` 110 | 111 | Print all open ports: 112 | 113 | ```sh 114 | $ np -ports [-path /path/to/scans] 115 | 22,80,443,9929,31337 116 | ``` 117 | 118 | Print all hosts with the given port open: 119 | 120 | ```sh 121 | $ np -port 80 [-path /path/to/scans] 122 | 45.33.32.156:80 123 | 159.223.119.162:80 124 | ``` 125 | 126 | Print all hosts with the given ports open: 127 | 128 | ```sh 129 | $ np -port 80,443 [-path /path/to/scans] 130 | 45.33.32.156:80 131 | 159.223.119.162:80 132 | 159.223.119.162:443 133 | ``` 134 | 135 | Print full JSON dump: 136 | 137 | ```sh 138 | $ np [-path /path/to/scans] -json 139 | [ 140 | { 141 | "ip": "45.33.32.156", 142 | "hostname": "scanme.nmap.org", 143 | "tcp_ports": { 144 | "22": { 145 | "name": "ssh", 146 | "product": "OpenSSH", 147 | "version": "6.6.1p1 Ubuntu 2ubuntu2.13", 148 | "extra_info": "Ubuntu Linux; protocol 2.0" 149 | }, 150 | "31337": { 151 | "name": "Elite" 152 | }, 153 | "80": { 154 | "name": "http", 155 | "product": "Apache httpd", 156 | "version": "2.4.7", 157 | "extra_info": "(Ubuntu)" 158 | }, 159 | "9929": { 160 | "name": "nping-echo", 161 | "product": "Nping echo" 162 | } 163 | } 164 | }, 165 | { 166 | "ip": "159.223.119.162", 167 | "hostname": "bishopfox.com", 168 | "tcp_ports": { 169 | "443": { 170 | "name": "https" 171 | }, 172 | "80": { 173 | "name": "http" 174 | } 175 | } 176 | } 177 | ] 178 | ``` 179 | 180 | ## Installation 181 | 182 | Make sure that `$GOPATH/bin` is part of `$PATH`, then: 183 | 184 | ```sh 185 | go install github.com/leesoh/np/cmd/np@latest 186 | ``` 187 | 188 | ## Similar Tools 189 | 190 | In case `np` isn't quite what you're looking for, here are a few similar tools: 191 | 192 | - [nmap-bootstrap-xsl](https://github.com/honze-net/nmap-bootstrap-xsl/) - Create nice looking HTML reports from Nmap scan output 193 | - [nmap-parse-output](https://github.com/ernw/nmap-parse-output) - Parse single Nmap scan output with extremely flexible output 194 | - [nmap-parse](https://github.com/jonny1102/nmap-parse) - Looks solid. If I had found this before writing `np` I might not have started :D 195 | - [ultimate-nmap-parsers](https://github.com/shifty0g/ultimate-nmap-parser) - Nice-looking parser with lots of output options 196 | 197 | ## Thanks 198 | 199 | - [go-nmap](https://github.com/lair-framework/go-nmap) - For making the XML parsing less awful 200 | - [naabu](https://github.com/projectdiscovery/naabu) - For the beautiful source code 201 | 202 | -------------------------------------------------------------------------------- /cmd/np/np.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/leesoh/np/internal/runner" 4 | 5 | func main() { 6 | options := runner.ParseOptions() 7 | r := runner.New(options) 8 | r.Run() 9 | } 10 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/leesoh/np 2 | 3 | go 1.16 4 | 5 | require github.com/Masterminds/log-go v1.0.0 6 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/Masterminds/log-go v1.0.0 h1:yjncypw3bbpezgjTSv+Jsy7+W5Pn/7S5RSoy+Wc8zCI= 2 | github.com/Masterminds/log-go v1.0.0/go.mod h1:l7N6BwMpaAz9Wn6f7YSz/OTpAbfiKqdB6t++H/EYWoM= 3 | github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= 4 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 5 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 6 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 7 | github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= 8 | github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= 9 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 10 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 11 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 12 | github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= 13 | github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= 14 | github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= 15 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= 16 | github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= 17 | github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= 18 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 19 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 20 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 21 | github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= 22 | github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 23 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 24 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 25 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 26 | github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= 27 | github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 28 | github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= 29 | go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= 30 | go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= 31 | go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= 32 | go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= 33 | go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= 34 | go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= 35 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 36 | golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 37 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 38 | golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 39 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 40 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 41 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 42 | golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= 43 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 44 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 45 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 46 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 47 | golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 48 | golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 49 | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 50 | golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 51 | golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 52 | golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 53 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 54 | golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 55 | golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60= 56 | golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 57 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= 58 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 59 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 60 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 61 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 62 | golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= 63 | golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= 64 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 65 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 66 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 67 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 68 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 69 | gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 70 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 71 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= 72 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 73 | -------------------------------------------------------------------------------- /internal/result/print.go: -------------------------------------------------------------------------------- 1 | package result 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "net" 7 | "os" 8 | "regexp" 9 | "strings" 10 | "text/tabwriter" 11 | ) 12 | 13 | // Print prints all hosts and the details of their open ports 14 | func (r *Result) Print() { 15 | r.SortByIP() 16 | for _, hh := range r.Hosts { 17 | // We have to do it here since some scans will add by IP. 18 | // So if we exclude example.com, but then massscan imports 19 | // the IP for example.com, we want to wait until the last minute 20 | // To ignore 21 | if hh.IsExcluded(r.Exclude) { 22 | continue 23 | } 24 | if hh.NotInCIDR(r.CIDR) { 25 | continue 26 | } 27 | r.hostPrinter(hh) 28 | r.portPrinter(hh) 29 | } 30 | } 31 | 32 | // PrintHost prints the full host details for the requested host (-host) 33 | func (r *Result) PrintHost(h *Host) { 34 | // Iterate through all hosts to find a match for the requested host 35 | for _, hh := range r.Hosts { 36 | if hh.IsExcluded(r.Exclude) { 37 | continue 38 | } 39 | if hh.NotInCIDR(r.CIDR) { 40 | continue 41 | } 42 | if hh.IP.Equal(h.IP) { 43 | r.hostPrinter(hh) 44 | } else if hh.Name != "" && hh.Name == h.Name { 45 | r.hostPrinter(hh) 46 | } else { 47 | continue 48 | } 49 | r.portPrinter(hh) 50 | } 51 | } 52 | 53 | func (r *Result) hostPrinter(h *Host) { 54 | if r.allPortsClosed(h) { 55 | return 56 | } 57 | if h.Name != "" { 58 | fmt.Printf("%v (%v)\n", h.Name, h.IP) 59 | } else { 60 | fmt.Printf("%v\n", h.IP) 61 | } 62 | } 63 | 64 | // portPrinter prints a nice port table 65 | func (r *Result) portPrinter(h *Host) { 66 | // We don't print ports if we don't have ports 67 | if h.allPortsClosed() { 68 | return 69 | } 70 | writer := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0) 71 | fmt.Fprintln(writer, "PORT\tSERVICE\tPRODUCT\tVERSION") 72 | // tcpwrapped are boring, do not print 73 | for k, v := range h.TCPPorts { 74 | if v.Name == "tcpwrapped" { 75 | continue 76 | } 77 | line := fmt.Sprintf("%v/%v\t%v\t%v\t%v", k, "tcp", v.Name, v.Product, v.Version) 78 | fmt.Fprintln(writer, line) 79 | } 80 | for k, v := range h.UDPPorts { 81 | if v.Name == "tcpwrapped" { 82 | continue 83 | } 84 | line := fmt.Sprintf("%v/%v\t%v\t%v\t%v", k, "udp", v.Name, v.Product, v.Version) 85 | fmt.Fprintln(writer, line) 86 | } 87 | writer.Flush() 88 | fmt.Println() 89 | } 90 | 91 | // PrintAlive prints all hosts with at least one open port (-hosts) 92 | func (r *Result) PrintAlive() { 93 | r.SortByIP() 94 | for _, hh := range r.Hosts { 95 | if hh.IsExcluded(r.Exclude) { 96 | continue 97 | } 98 | if hh.NotInCIDR(r.CIDR) { 99 | continue 100 | } 101 | if r.allPortsClosed(hh) { 102 | r.Logger.Debugf("all ports closed: %v", hh.IP) 103 | continue 104 | } 105 | // Prefer hostname over IP 106 | if hh.Name != "" { 107 | r.Logger.Debugf("%v", hh.Name) 108 | fmt.Printf("%v (%v)\n", hh.Name, hh.IP) 109 | } else { 110 | fmt.Printf("%v\n", hh.IP) 111 | } 112 | } 113 | } 114 | 115 | // PrintByService prints a specific service (-service) 116 | func (r *Result) PrintByService(service string) { 117 | r.SortByIP() 118 | var hosts []string 119 | for _, hh := range r.Hosts { 120 | if hh.IsExcluded(r.Exclude) { 121 | continue 122 | } 123 | if hh.NotInCIDR(r.CIDR) { 124 | continue 125 | } 126 | if r.allPortsClosed(hh) { 127 | continue 128 | } 129 | for k, v := range hh.TCPPorts { 130 | if matched, _ := regexp.MatchString(service, v.Name); matched { 131 | r.Logger.Debugf("matched: %v", hh.GetName()) 132 | s := r.formatService(hh.GetName(), k, v.Name) 133 | hosts = append(hosts, s) 134 | } 135 | } 136 | for k, v := range hh.UDPPorts { 137 | if matched, _ := regexp.MatchString(service, v.Name); matched { 138 | r.Logger.Debugf("matched: %v", hh.GetName()) 139 | s := r.formatService(hh.GetName(), k, v.Name) 140 | hosts = append(hosts, s) 141 | } 142 | } 143 | } 144 | for _, hh := range hosts { 145 | fmt.Println(hh) 146 | } 147 | } 148 | 149 | // PrintService prints all services in host:port service format (-services) 150 | func (r *Result) PrintServices() { 151 | r.SortByIP() 152 | var hosts []string 153 | for _, hh := range r.Hosts { 154 | if hh.IsExcluded(r.Exclude) { 155 | continue 156 | } 157 | if hh.NotInCIDR(r.CIDR) { 158 | continue 159 | } 160 | for k, v := range hh.TCPPorts { 161 | r.Logger.Debugf("matched: %v", hh.GetName()) 162 | s := r.formatService(hh.GetName(), k, v.Name) 163 | hosts = append(hosts, s) 164 | } 165 | for k, v := range hh.UDPPorts { 166 | r.Logger.Debugf("matched: %v", hh.GetName()) 167 | s := r.formatService(hh.GetName(), k, v.Name) 168 | hosts = append(hosts, s) 169 | } 170 | } 171 | for _, hh := range hosts { 172 | fmt.Println(hh) 173 | } 174 | } 175 | 176 | func (r *Result) formatService(name string, port int, service string) string { 177 | return fmt.Sprintf("%v:%v %v", name, port, service) 178 | } 179 | 180 | // PrintByPort prints all hosts with a specific port open (-port) 181 | func (r *Result) PrintByPort(port []int) { 182 | r.SortByIP() 183 | for _, hh := range r.Hosts { 184 | if hh.IsExcluded(r.Exclude) { 185 | continue 186 | } 187 | if hh.NotInCIDR(r.CIDR) { 188 | continue 189 | } 190 | if r.allPortsClosed(hh) { 191 | continue 192 | } 193 | for _, pp := range port { 194 | if _, hasPort := hh.TCPPorts[pp]; hasPort { 195 | r.Logger.Debugf("%v has pp: %v", hh.Name, pp) 196 | fmt.Printf("%v:%v\n", hh.IP, pp) 197 | } 198 | if _, hasPort := hh.UDPPorts[pp]; hasPort { 199 | r.Logger.Debugf("%v has pp: %v", hh.Name, pp) 200 | fmt.Printf("%v:%v\n", hh.IP, pp) 201 | } 202 | } 203 | } 204 | } 205 | 206 | // PrintPortSummary prints a comma-delimited list of ports (-ports) 207 | func (r *Result) PrintPortSummary() { 208 | p := make(map[int]struct{}) 209 | for _, hh := range r.Hosts { 210 | if hh.IsExcluded(r.Exclude) { 211 | continue 212 | } 213 | if hh.NotInCIDR(r.CIDR) { 214 | continue 215 | } 216 | for k := range hh.TCPPorts { 217 | p[k] = struct{}{} 218 | } 219 | for k := range hh.UDPPorts { 220 | p[k] = struct{}{} 221 | } 222 | } 223 | sorted := sortIntMap(p) 224 | var ps strings.Builder 225 | for _, k := range sorted { 226 | s := fmt.Sprintf("%s,", fmt.Sprint(k)) 227 | ps.WriteString(s) 228 | } 229 | fmt.Println(strings.TrimSuffix(ps.String(), ",")) 230 | } 231 | 232 | func (r *Result) printIfValue(s string) { 233 | if s != "" { 234 | fmt.Println(s) 235 | } 236 | } 237 | 238 | func (r *Result) PrintJSON() { 239 | r.SortByIP() 240 | b, err := json.MarshalIndent(r.Hosts, "", " ") 241 | if err != nil { 242 | r.Logger.Error(err) 243 | } 244 | fmt.Println(string(b)) 245 | } 246 | 247 | func (r *Result) PrintableIPList(ips []net.IP) string { 248 | var ipList strings.Builder 249 | for _, ii := range ips { 250 | fmt.Fprintf(&ipList, "%v,", ii) 251 | } 252 | return strings.TrimSuffix(ipList.String(), ",") 253 | } 254 | 255 | func (r *Result) allPortsClosed(h *Host) bool { 256 | if len(h.TCPPorts) == 0 && len(h.UDPPorts) == 0 { 257 | r.Logger.Debugf("no open ports on host: %v", h.IP) 258 | return true 259 | } 260 | return false 261 | } 262 | -------------------------------------------------------------------------------- /internal/result/result.go: -------------------------------------------------------------------------------- 1 | package result 2 | 3 | import ( 4 | "bytes" 5 | "net" 6 | "sort" 7 | 8 | "github.com/Masterminds/log-go/impl/cli" 9 | ) 10 | 11 | type Result struct { 12 | Logger *cli.Logger 13 | Hosts []*Host 14 | Exclude []string 15 | CIDR *net.IPNet 16 | } 17 | 18 | func (r *Result) SortByIP() { 19 | sort.Slice(r.Hosts, func(p, q int) bool { 20 | return bytes.Compare(r.Hosts[p].IP, r.Hosts[q].IP) < 0 21 | }) 22 | 23 | } 24 | 25 | func New(logger *cli.Logger, exclude []string, cidr string) *Result { 26 | c, err := parseCIDR(cidr) 27 | if err != nil { 28 | logger.Errorf("error parsing CIDR: %s", err) 29 | } 30 | return &Result{ 31 | Logger: logger, 32 | Exclude: exclude, 33 | CIDR: c, 34 | } 35 | } 36 | 37 | func parseCIDR(cidr string) (*net.IPNet, error) { 38 | _, c, err := net.ParseCIDR(cidr) 39 | if err != nil { 40 | return nil, err 41 | } 42 | return c, nil 43 | } 44 | 45 | func (r *Result) AddHost(newHost *Host) { 46 | r.Logger.Debugf("processing host: %v", newHost.IP) 47 | // We search our list of hosts for a match. If one is found, 48 | // we add ports. 49 | for _, hh := range r.Hosts { 50 | // Don't process 51 | if hh.IP.Equal(newHost.IP) { 52 | r.Logger.Debugf("found existing host: %v", hh.IP) 53 | hh.updateName(newHost.Name) 54 | r.Logger.Debugf("adding ports to %v", hh.IP) 55 | hh.addTCPPorts(newHost.TCPPorts) 56 | hh.addUDPPorts(newHost.UDPPorts) 57 | return 58 | } 59 | } 60 | // We didn't find an existing host, add this one 61 | r.Logger.Debugf("found new host: %v", newHost.IP) 62 | // good to here 63 | r.Hosts = append(r.Hosts, newHost) 64 | } 65 | 66 | type Host struct { 67 | IP net.IP `json:"ip"` 68 | Name string `json:"hostname,omitempty"` 69 | TCPPorts map[int]*Port `json:"tcp_ports,omitempty"` 70 | UDPPorts map[int]*Port `json:"udp_ports,omitempty"` 71 | } 72 | 73 | func (h *Host) IsExcluded(el []string) bool { 74 | for _, ee := range el { 75 | if h.IP.String() == ee || h.Name == ee { 76 | return true 77 | } 78 | } 79 | return false 80 | } 81 | 82 | func (h *Host) NotInCIDR(c *net.IPNet) bool { 83 | return !c.Contains(h.IP) 84 | } 85 | 86 | func (h *Host) updateName(hostname string) { 87 | // Don't overwrite 88 | if h.Name == "" && hostname != "" { 89 | h.Name = hostname 90 | } 91 | } 92 | 93 | func (h *Host) addTCPPorts(p map[int]*Port) { 94 | for k, v := range p { 95 | h.addOrUpdatePort(k, v, "tcp") 96 | } 97 | } 98 | 99 | func (h *Host) addUDPPorts(p map[int]*Port) { 100 | for k, v := range p { 101 | h.addOrUpdatePort(k, v, "udp") 102 | } 103 | } 104 | 105 | func (h *Host) addOrUpdatePort(k int, p *Port, proto string) { 106 | if proto == "tcp" { 107 | if _, hasPort := h.TCPPorts[k]; !hasPort { 108 | h.TCPPorts[k] = p 109 | return 110 | } 111 | h.TCPPorts[k].Update(p) 112 | } 113 | if proto == "udp" { 114 | if _, hasPort := h.UDPPorts[k]; !hasPort { 115 | h.UDPPorts[k] = p 116 | return 117 | } 118 | h.UDPPorts[k].Update(p) 119 | } 120 | } 121 | 122 | func (h *Host) allPortsClosed() bool { 123 | return len(h.TCPPorts) == 0 && len(h.UDPPorts) == 0 124 | } 125 | 126 | func (h *Host) GetName() string { 127 | if h.Name != "" { 128 | return h.Name 129 | } else { 130 | return h.IP.String() 131 | } 132 | } 133 | 134 | type Port struct { 135 | Name string `json:"name,omitempty"` 136 | Product string `json:"product,omitempty"` 137 | Version string `json:"version,omitempty"` 138 | ExtraInfo string `json:"extra_info,omitempty"` 139 | } 140 | 141 | func (p *Port) Update(portData *Port) { 142 | if portData.Name == "" && p.Name != "" { 143 | portData.Name = p.Name 144 | } 145 | if portData.Product == "" && p.Product != "" { 146 | portData.Product = p.Product 147 | } 148 | if portData.Version == "" && p.Version != "" { 149 | portData.Version = p.Version 150 | } 151 | if portData.ExtraInfo == "" && p.ExtraInfo != "" { 152 | portData.ExtraInfo = p.ExtraInfo 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /internal/result/util.go: -------------------------------------------------------------------------------- 1 | package result 2 | 3 | import ( 4 | "sort" 5 | ) 6 | 7 | func sortStringMap(m map[string]struct{}) []string { 8 | var keys []string 9 | for kk := range m { 10 | keys = append(keys, kk) 11 | } 12 | sort.Strings(keys) 13 | return keys 14 | } 15 | 16 | func sortIntMap(m map[int]struct{}) []int { 17 | var keys []int 18 | for kk := range m { 19 | keys = append(keys, kk) 20 | } 21 | sort.Ints(keys) 22 | return keys 23 | } 24 | -------------------------------------------------------------------------------- /internal/runner/options.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "flag" 5 | "strconv" 6 | "strings" 7 | 8 | "github.com/Masterminds/log-go" 9 | "github.com/Masterminds/log-go/impl/cli" 10 | ) 11 | 12 | type Options struct { 13 | Exclude []string 14 | JSON bool 15 | Host string 16 | Hosts bool 17 | CIDR string 18 | Path string 19 | Port []int 20 | Ports bool 21 | Service string 22 | Services bool 23 | Debug bool 24 | } 25 | 26 | func ParseOptions() *Options { 27 | options := &Options{} 28 | logger := cli.NewStandard() 29 | logger.Level = log.ErrorLevel 30 | exclude := flag.String("exclude", "", "Exclude these hosts from output") 31 | flag.BoolVar(&options.JSON, "json", false, "Display JSON output") 32 | flag.StringVar(&options.Host, "host", "", "Show results for specified host") 33 | flag.BoolVar(&options.Hosts, "hosts", false, "Print alive hosts") 34 | flag.StringVar(&options.CIDR, "cidr", "0.0.0.0/0", "CIDR range to output") 35 | flag.StringVar(&options.Path, "path", ".", "Path to scan file") 36 | port := flag.String("port", "", "Display hosts with matching port(s)") 37 | flag.BoolVar(&options.Ports, "ports", false, "Print all ports") 38 | flag.StringVar(&options.Service, "service", "", "Display hosts with matching service name") 39 | flag.BoolVar(&options.Services, "services", false, "Print all services") 40 | flag.BoolVar(&options.Debug, "debug", false, "Display debug output") 41 | flag.Parse() 42 | if *port != "" { 43 | pl := strings.Split(*port, ",") 44 | for _, pp := range pl { 45 | pi, err := strconv.Atoi(pp) 46 | if err != nil { 47 | continue 48 | } 49 | options.Port = append(options.Port, pi) 50 | } 51 | } 52 | if *exclude != "" { 53 | el := strings.Split(*exclude, ",") 54 | options.Exclude = append(options.Exclude, el...) 55 | } 56 | return options 57 | } 58 | -------------------------------------------------------------------------------- /internal/runner/runner.go: -------------------------------------------------------------------------------- 1 | package runner 2 | 3 | import ( 4 | "io/fs" 5 | "io/ioutil" 6 | "net" 7 | "path/filepath" 8 | 9 | "github.com/Masterminds/log-go" 10 | "github.com/Masterminds/log-go/impl/cli" 11 | "github.com/leesoh/np/internal/result" 12 | "github.com/leesoh/np/internal/scan" 13 | ) 14 | 15 | type Runner struct { 16 | Files []string 17 | Logger *cli.Logger 18 | Options *Options 19 | } 20 | 21 | func New(options *Options) *Runner { 22 | logger := cli.NewStandard() 23 | if options.Debug { 24 | logger.Level = log.DebugLevel 25 | } else { 26 | logger.Level = log.ErrorLevel 27 | } 28 | runner := &Runner{ 29 | Logger: logger, 30 | Options: options, 31 | } 32 | return runner 33 | } 34 | 35 | func (r *Runner) Run() { 36 | r.GetScanFiles() 37 | res := result.New(r.Logger, r.Options.Exclude, r.Options.CIDR) 38 | for _, ff := range r.Files { 39 | r.Logger.Debugf("processing %v", ff) 40 | // Get last modified time for timeline output 41 | b, err := ioutil.ReadFile(ff) 42 | if err != nil { 43 | r.Logger.Errorf("error reading file: %v", err) 44 | } 45 | s := scan.New(b, r.Logger, res) 46 | // If we don't process this first it will overwrite other scans 47 | if s.IsNP() { 48 | r.Logger.Debugf("found np scan: %s", ff) 49 | // We have to send the exclude list so we don't process previously saved hosts 50 | s.ParseNP(r.Options.Exclude) 51 | } 52 | // This handles both Nmap and Masscan files as they have the same structure 53 | if s.IsNmap() { 54 | r.Logger.Debugf("found nmap scan: %s", ff) 55 | s.ParseNmap() 56 | } 57 | if s.IsNaabuV1() { 58 | r.Logger.Debugf("found naabu v1 scan: %s", ff) 59 | s.ParseNaabuV1() 60 | } 61 | if s.IsNaabuV2() { 62 | r.Logger.Debugf("found naabu v2 scan: %s", ff) 63 | s.ParseNaabuV2() 64 | } 65 | if s.IsDNSx() { 66 | r.Logger.Debugf("found DNSx scan: %s", ff) 67 | s.ParseDNSx() 68 | } 69 | } 70 | // -host 71 | if r.Options.Host != "" { 72 | ip := net.ParseIP(r.Options.Host) 73 | h := &result.Host{} 74 | if ip == nil { 75 | h.Name = r.Options.Host 76 | } else { 77 | h.IP = ip 78 | } 79 | res.PrintHost(h) 80 | return 81 | } 82 | // -hosts 83 | if r.Options.Hosts { 84 | res.PrintAlive() 85 | return 86 | } 87 | // -service 88 | if r.Options.Service != "" { 89 | res.PrintByService(r.Options.Service) 90 | return 91 | } 92 | // -services 93 | if r.Options.Services { 94 | res.PrintServices() 95 | return 96 | } 97 | // -port 98 | if r.Options.Port != nil { 99 | res.PrintByPort(r.Options.Port) 100 | return 101 | } 102 | // -ports 103 | if r.Options.Ports { 104 | res.PrintPortSummary() 105 | return 106 | } 107 | // -json 108 | if r.Options.JSON { 109 | res.PrintJSON() 110 | return 111 | } 112 | r.Logger.Debugf("no options selected, printing default") 113 | res.Print() 114 | } 115 | 116 | // GetScanFiles gathers scan files from the provided path 117 | func (r *Runner) GetScanFiles() { 118 | r.Logger.Debugf("searching path: %v", r.Options.Path) 119 | err := filepath.WalkDir(r.Options.Path, r.walkScans) 120 | if err != nil { 121 | r.Logger.Errorf("error parsing path: %v", err) 122 | } 123 | } 124 | 125 | // walkScans walks the provided path and queues likely scan files for parsing 126 | func (r *Runner) walkScans(path string, d fs.DirEntry, err error) error { 127 | // TODO: I'm not sure why this is here 128 | if err != nil { 129 | return err 130 | } 131 | r.Logger.Debugf("found file: %v", filepath.Base(path)) 132 | switch filepath.Ext(path) { 133 | case ".xml": 134 | r.Files = append(r.Files, path) 135 | r.Logger.Debugf("queued XML file for processing: %v", filepath.Base(path)) 136 | case ".json": 137 | r.Files = append(r.Files, path) 138 | r.Logger.Debugf("queued JSON file for processing: %v", filepath.Base(path)) 139 | default: 140 | r.Logger.Debugf("unsupported file type: %v", filepath.Base(path)) 141 | } 142 | return nil 143 | } 144 | -------------------------------------------------------------------------------- /internal/scan/dnsx/dnsx.go: -------------------------------------------------------------------------------- 1 | package dnsx 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "encoding/json" 7 | "fmt" 8 | ) 9 | 10 | //{ 11 | // "host": "approval-bot.it.epicgames.com", 12 | // "resolver": [ 13 | // "8.8.8.8:53" 14 | // ], 15 | // "a": [ 16 | // "34.225.117.206" 17 | // ], 18 | // "status_code": "NOERROR", 19 | // "timestamp": "2022-05-10T10:54:41.294781206-06:00" 20 | //} 21 | 22 | type DNSxScan struct { 23 | Records []*Record 24 | } 25 | 26 | type Record struct { 27 | IPAddresses []string `json:"a"` 28 | Hostname string `json:"host"` 29 | } 30 | 31 | func Parse(scan []byte) (*DNSxScan, error) { 32 | s := &DNSxScan{} 33 | // DNSx scan is JSONL, so we have to read it line by line 34 | sc := bufio.NewScanner(bytes.NewReader(scan)) 35 | sc.Split(bufio.ScanLines) 36 | for sc.Scan() { 37 | r := &Record{} 38 | err := json.Unmarshal(sc.Bytes(), &r) 39 | if err != nil { 40 | return nil, fmt.Errorf("error unmarshaling DNSx: %v", err) 41 | } 42 | // Incomplete data, move on 43 | if isMissingKeys(r) { 44 | continue 45 | } 46 | s.Records = append(s.Records, r) 47 | } 48 | return s, nil 49 | } 50 | 51 | // isMissingKeys attempts to filter non-DNSx JSON files (e.g. Amass output) 52 | func isMissingKeys(r *Record) bool { 53 | // Every host should have both of these 54 | if len(r.IPAddresses) == 0 || r.Hostname == "" { 55 | return true 56 | } 57 | return false 58 | } 59 | -------------------------------------------------------------------------------- /internal/scan/naabu/naabu.go: -------------------------------------------------------------------------------- 1 | package naabu 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "encoding/json" 7 | "fmt" 8 | "time" 9 | ) 10 | 11 | type NaabuScan struct { 12 | V1Hosts []*HostV1 13 | V2Hosts []*HostV2 14 | } 15 | 16 | type HostV1 struct { 17 | Name string `json:"host"` 18 | IPAddress string `json:"ip"` 19 | Port int `json:"port"` 20 | } 21 | 22 | type HostV2 struct { 23 | Name string `json:"host"` 24 | IPAddress string `json:"ip"` 25 | Port Port `json:"port"` 26 | Timestamp time.Time `json:"timestamp"` 27 | } 28 | 29 | type Port struct { 30 | Port int `json:"Port"` 31 | Protocol int `json:"Protocol"` 32 | TLS bool `json:"TLS"` 33 | } 34 | 35 | func ParseV1(scan []byte) (*NaabuScan, error) { 36 | s := &NaabuScan{} 37 | // Naabu scan is JSONL, so we have to read it line by line 38 | sc := bufio.NewScanner(bytes.NewReader(scan)) 39 | sc.Split(bufio.ScanLines) 40 | for sc.Scan() { 41 | hv1 := &HostV1{} 42 | err := json.Unmarshal(sc.Bytes(), &hv1) 43 | if err != nil { 44 | return nil, fmt.Errorf("error unmarshaling naabu V1: %v", err) 45 | } 46 | if isMissingV1Keys(hv1) { 47 | return nil, fmt.Errorf("missing Naabu keys") 48 | } 49 | s.V1Hosts = append(s.V1Hosts, hv1) 50 | } 51 | return s, nil 52 | } 53 | 54 | func ParseV2(scan []byte) (*NaabuScan, error) { 55 | s := &NaabuScan{} 56 | // Naabu scan is JSONL, so we have to read it line by line 57 | sc := bufio.NewScanner(bytes.NewReader(scan)) 58 | sc.Split(bufio.ScanLines) 59 | for sc.Scan() { 60 | hv2 := &HostV2{} 61 | err := json.Unmarshal(sc.Bytes(), &hv2) 62 | if err != nil { 63 | return nil, fmt.Errorf("error unmarshaling naabu V2: %v", err) 64 | } 65 | if isMissingV2Keys(hv2) { 66 | return nil, fmt.Errorf("missing Naabu keys") 67 | } 68 | s.V2Hosts = append(s.V2Hosts, hv2) 69 | } 70 | return s, nil 71 | } 72 | 73 | // isMissingV1Keys attempts to filter non-Naabu JSON files (e.g. Amass output) 74 | func isMissingV1Keys(h *HostV1) bool { 75 | // Every host should have one of these 76 | if h.IPAddress == "" || h.Port == 0 { 77 | return true 78 | } 79 | return false 80 | } 81 | 82 | // isMissingV2Keys attempts to filter non-Naabu JSON files (e.g. Amass output) 83 | func isMissingV2Keys(h *HostV2) bool { 84 | // Every host should have one of these 85 | if h.IPAddress == "" || h.Port.Port == 0 { 86 | return true 87 | } 88 | return false 89 | } 90 | -------------------------------------------------------------------------------- /internal/scan/nmap/nmap.go: -------------------------------------------------------------------------------- 1 | package nmap 2 | 3 | import ( 4 | "encoding/xml" 5 | "fmt" 6 | ) 7 | 8 | // Thanks to lair-framework/go-nmap for making this simpler 9 | type NmapScan struct { 10 | XMLName xml.Name `xml:"nmaprun"` 11 | Text string `xml:",chardata"` 12 | Scanner string `xml:"scanner,attr"` 13 | Args string `xml:"args,attr"` 14 | Start string `xml:"start,attr"` 15 | Startstr string `xml:"startstr,attr"` 16 | Version string `xml:"version,attr"` 17 | XMLOutputVersion string `xml:"xmloutputversion,attr"` 18 | ScanInfo ScanInfo `xml:"scaninfo"` 19 | Verbose Verbose `xml:"verbose"` 20 | Debugging Debugging `xml:"debugging"` 21 | Hosts []Host `xml:"host"` 22 | RunStats RunStats `xml:"runstats"` 23 | } 24 | 25 | type ScanInfo struct { 26 | Text string `xml:",chardata"` 27 | Type string `xml:"type,attr"` 28 | Protocol string `xml:"protocol,attr"` 29 | NumServices string `xml:"numservices,attr"` 30 | Services string `xml:"services,attr"` 31 | } 32 | 33 | type Verbose struct { 34 | Text string `xml:",chardata"` 35 | Level string `xml:"level,attr"` 36 | } 37 | 38 | type Debugging struct { 39 | Text string `xml:",chardata"` 40 | Level string `xml:"level,attr"` 41 | } 42 | 43 | type RunStats struct { 44 | Text string `xml:",chardata"` 45 | Finished Finished `xml:"finished"` 46 | Hosts Hosts `xml:"hosts"` 47 | } 48 | 49 | type Finished struct { 50 | Text string `xml:",chardata"` 51 | Time string `xml:"time,attr"` 52 | Timestr string `xml:"timestr,attr"` 53 | Elapsed string `xml:"elapsed,attr"` 54 | Summary string `xml:"summary,attr"` 55 | Exit string `xml:"exit,attr"` 56 | } 57 | 58 | type Hosts struct { 59 | Text string `xml:",chardata"` 60 | Up string `xml:"up,attr"` 61 | Down string `xml:"down,attr"` 62 | Total string `xml:"total,attr"` 63 | } 64 | 65 | type Host struct { 66 | Text string `xml:",chardata"` 67 | StartTime string `xml:"starttime,attr"` 68 | EndTime string `xml:"endtime,attr"` 69 | Status Status `xml:"status"` 70 | Address Address `xml:"address"` 71 | Hostnames []Hostname `xml:"hostnames>hostname"` 72 | Ports []Port `xml:"ports>port"` 73 | Times Times `xml:"times"` 74 | } 75 | 76 | type Status struct { 77 | Text string `xml:",chardata"` 78 | State string `xml:"state,attr"` 79 | Reason string `xml:"reason,attr"` 80 | ReasonTTL string `xml:"reason_ttl,attr"` 81 | } 82 | 83 | type Address struct { 84 | Text string `xml:",chardata"` 85 | Addr string `xml:"addr,attr"` 86 | Addrtype string `xml:"addrtype,attr"` 87 | } 88 | 89 | type Hostname struct { 90 | Text string `xml:",chardata"` 91 | Name string `xml:"name,attr"` 92 | Type string `xml:"type,attr"` 93 | } 94 | 95 | type Port struct { 96 | Text string `xml:",chardata"` 97 | Protocol string `xml:"protocol,attr"` 98 | PortID string `xml:"portid,attr"` 99 | State State `xml:"state"` 100 | Service Service `xml:"service"` 101 | } 102 | 103 | type State struct { 104 | Text string `xml:",chardata"` 105 | State string `xml:"state,attr"` 106 | Reason string `xml:"reason,attr"` 107 | ReasonTTL string `xml:"reason_ttl,attr"` 108 | } 109 | 110 | type Service struct { 111 | Conf string `xml:"conf,attr"` 112 | Method string `xml:"method,attr"` 113 | Name string `xml:"name,attr"` 114 | Product string `xml:"product,attr"` 115 | Version string `xml:"version,attr"` 116 | ExtraInfo string `xml:"extrainfo,attr"` 117 | Text string `xml:",chardata"` 118 | } 119 | 120 | type Times struct { 121 | Text string `xml:",chardata"` 122 | SRTT string `xml:"srtt,attr"` 123 | RTTVar string `xml:"rttvar,attr"` 124 | To string `xml:"to,attr"` 125 | } 126 | 127 | func Parse(scan []byte) (*NmapScan, error) { 128 | s := &NmapScan{} 129 | err := xml.Unmarshal(scan, s) 130 | if err != nil { 131 | return nil, fmt.Errorf("error unmarshaling Nmap: %v", err) 132 | } 133 | return s, nil 134 | } 135 | -------------------------------------------------------------------------------- /internal/scan/np.go: -------------------------------------------------------------------------------- 1 | package scan 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | 7 | "github.com/leesoh/np/internal/result" 8 | ) 9 | 10 | func (s *Scan) IsNP() bool { 11 | var h []*result.Host 12 | dec := json.NewDecoder(bytes.NewReader(s.Bytes)) 13 | dec.DisallowUnknownFields() 14 | if err := dec.Decode(&h); err != nil { 15 | s.Logger.Debugf("not np output") 16 | return false 17 | } 18 | s.Logger.Debugf("found valid np results") 19 | return true 20 | } 21 | 22 | func (s *Scan) ParseNP(el []string) { 23 | var hosts []*result.Host 24 | // We're importing an old np session so just unpack into results 25 | err := json.Unmarshal(s.Bytes, &hosts) 26 | if err != nil { 27 | s.Logger.Errorf("error unmarshaling np results: %v", err) 28 | } 29 | for _, hh := range hosts { 30 | s.Result.AddHost(hh) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /internal/scan/scan.go: -------------------------------------------------------------------------------- 1 | package scan 2 | 3 | import ( 4 | "net" 5 | "strconv" 6 | 7 | "github.com/Masterminds/log-go/impl/cli" 8 | "github.com/leesoh/np/internal/result" 9 | "github.com/leesoh/np/internal/scan/dnsx" 10 | "github.com/leesoh/np/internal/scan/naabu" 11 | "github.com/leesoh/np/internal/scan/nmap" 12 | ) 13 | 14 | type Scan struct { 15 | Bytes []byte 16 | Logger *cli.Logger 17 | Result *result.Result 18 | } 19 | 20 | func New(b []byte, logger *cli.Logger, r *result.Result) *Scan { 21 | return &Scan{ 22 | Bytes: b, 23 | Logger: logger, 24 | Result: r, 25 | } 26 | } 27 | 28 | func (s *Scan) IsNmap() bool { 29 | if _, err := nmap.Parse(s.Bytes); err != nil { 30 | s.Logger.Debug("not an Nmap scan") 31 | return false 32 | } 33 | return true 34 | } 35 | 36 | func (s *Scan) ParseNmap() { 37 | ns, err := nmap.Parse(s.Bytes) 38 | if err != nil { 39 | s.Logger.Errorf("error parsing Nmap scan: %v", err) 40 | } 41 | for _, hh := range ns.Hosts { 42 | h := &result.Host{ 43 | Name: s.getNmapHostname(hh), 44 | IP: s.stringToIP(hh.Address.Addr), 45 | TCPPorts: s.getNmapPorts(hh, "tcp"), 46 | UDPPorts: s.getNmapPorts(hh, "udp"), 47 | } 48 | s.Result.AddHost(h) 49 | s.Logger.Debugf("added host: %v", h.IP) 50 | } 51 | } 52 | 53 | func (s *Scan) getNmapHostname(h nmap.Host) string { 54 | for _, hh := range h.Hostnames { 55 | if hh.Type == "user" { 56 | s.Logger.Debugf("found hostname: %v", hh.Name) 57 | return hh.Name 58 | } 59 | } 60 | return "" 61 | } 62 | 63 | func (s *Scan) stringToIP(ipString string) net.IP { 64 | ip := net.ParseIP(ipString) 65 | if ip != nil { 66 | s.Logger.Debugf("added IP: %v", ip) 67 | return ip 68 | } 69 | return nil 70 | } 71 | 72 | func (s *Scan) getNmapPorts(h nmap.Host, protocol string) map[int]*result.Port { 73 | ports := make(map[int]*result.Port) 74 | for _, pp := range h.Ports { 75 | if pp.State.State == "open" && pp.Protocol == protocol { 76 | number, err := strconv.Atoi(pp.PortID) 77 | if err != nil { 78 | s.Logger.Errorf("error casting port: %v", pp.PortID) 79 | } 80 | port := &result.Port{ 81 | Name: pp.Service.Name, 82 | Product: pp.Service.Product, 83 | Version: pp.Service.Version, 84 | ExtraInfo: pp.Service.ExtraInfo, 85 | } 86 | ports[number] = port 87 | s.Logger.Debugf("found port: %v/%v", number, protocol) 88 | } 89 | } 90 | return ports 91 | } 92 | 93 | // IsNaabuV1 checks whether the v2.1.11 or earlier template is used. 94 | // I'm calling it IsNaabuV1 since it's the first type of output they used. 95 | func (s *Scan) IsNaabuV1() bool { 96 | if _, err := naabu.ParseV1(s.Bytes); err != nil { 97 | s.Logger.Debugf("not a Naabu V1 scan: %v", err) 98 | return false 99 | } 100 | return true 101 | } 102 | 103 | // IsNaabuV2 checks whether the v2.1.11 or earlier template is used. 104 | // I'm calling it IsNaabuV2 since it's the first type of output they used. 105 | func (s *Scan) IsNaabuV2() bool { 106 | if _, err := naabu.ParseV2(s.Bytes); err != nil { 107 | s.Logger.Debugf("not a Naabu V2 scan: %v", err) 108 | return false 109 | } 110 | return true 111 | } 112 | 113 | func (s *Scan) ParseNaabuV1() { 114 | ns, err := naabu.ParseV1(s.Bytes) 115 | if err != nil { 116 | s.Logger.Errorf("error parsing Naabu scan: %v", err) 117 | } 118 | for _, hh := range ns.V1Hosts { 119 | h := &result.Host{ 120 | Name: hh.Name, 121 | IP: s.stringToIP(hh.IPAddress), 122 | TCPPorts: s.intToPort(hh.Port), 123 | UDPPorts: map[int]*result.Port{}, // Naabu V1 format 124 | } 125 | s.Result.AddHost(h) 126 | s.Logger.Debugf("added host: %v", h.IP) 127 | } 128 | } 129 | 130 | func (s *Scan) ParseNaabuV2() { 131 | ns, err := naabu.ParseV2(s.Bytes) 132 | if err != nil { 133 | s.Logger.Errorf("error parsing Naabu scan: %v", err) 134 | } 135 | for _, hh := range ns.V2Hosts { 136 | h := &result.Host{ 137 | Name: hh.Name, 138 | IP: s.stringToIP(hh.IPAddress), 139 | } 140 | // https://github.com/projectdiscovery/naabu/blob/46dc6d250523f0047532d6009017863a6276040b/v2/pkg/protocol/protocol.go#L6 141 | switch hh.Port.Protocol { 142 | case 0: 143 | h.TCPPorts = s.intToPort(hh.Port.Port) 144 | case 1: 145 | h.UDPPorts = s.intToPort(hh.Port.Port) 146 | default: 147 | s.Logger.Debugf("unsupported protocol") 148 | } 149 | s.Result.AddHost(h) 150 | s.Logger.Debugf("added host: %v", h.IP) 151 | } 152 | } 153 | 154 | func (s *Scan) intToPort(portInt int) map[int]*result.Port { 155 | ports := make(map[int]*result.Port) 156 | ports[portInt] = &result.Port{} 157 | return ports 158 | } 159 | 160 | func (s *Scan) IsDNSx() bool { 161 | if _, err := dnsx.Parse(s.Bytes); err != nil { 162 | s.Logger.Debugf("not a DNSx scan: %v", err) 163 | return false 164 | } 165 | return true 166 | } 167 | 168 | func (s *Scan) ParseDNSx() { 169 | ds, err := dnsx.Parse(s.Bytes) 170 | if err != nil { 171 | s.Logger.Errorf("error parsing DNSx scan: %v", err) 172 | } 173 | for _, rr := range ds.Records { 174 | // We will add each IP:host mapping as a discrete host 175 | for i := range rr.IPAddresses { 176 | h := &result.Host{ 177 | Name: rr.Hostname, 178 | IP: s.stringToIP(rr.IPAddresses[i]), 179 | TCPPorts: map[int]*result.Port{}, 180 | UDPPorts: map[int]*result.Port{}, 181 | } 182 | s.Result.AddHost(h) 183 | s.Logger.Debugf("added host: %v", h.Name) 184 | } 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /testdata/123_udp_version.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /testdata/80_443.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /testdata/80_443_version.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | cpe:/a:apache:http_server:2.4.7 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /testdata/default_by_ip.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /testdata/default_by_name_version_script.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | cpe:/a:openbsd:openssh:6.6.1p1cpe:/o:linux:linux_kernel 44 | 45 | cpe:/a:apache:http_server:2.4.7 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /testdata/masscan.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 |
8 |
9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /testdata/multi_host_80_443.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /testdata/naabu-all-top-25.json: -------------------------------------------------------------------------------- 1 | {"host":"bishopfox.com","ip":"172.67.83.42","port":80} 2 | {"host":"bishopfox.com","ip":"172.67.83.42","port":443} 3 | {"host":"bishopfox.com","ip":"172.67.83.42","port":8443} 4 | {"host":"bishopfox.com","ip":"172.67.83.42","port":8080} 5 | {"host":"scanme.nmap.org","ip":"45.33.32.156","port":80} 6 | {"host":"scanme.nmap.org","ip":"45.33.32.156","port":22} 7 | -------------------------------------------------------------------------------- /testdata/naabu-v2-all-top-100.json: -------------------------------------------------------------------------------- 1 | {"host":"bishopfox.com","ip":"172.67.83.42","port":{"Port":443,"Protocol":0,"TLS":false},"timestamp":"2023-08-11T15:10:01.790532696Z"} 2 | {"host":"bishopfox.com","ip":"172.67.83.42","port":{"Port":8443,"Protocol":0,"TLS":false},"timestamp":"2023-08-11T15:10:01.790532696Z"} 3 | {"host":"bishopfox.com","ip":"172.67.83.42","port":{"Port":8080,"Protocol":0,"TLS":false},"timestamp":"2023-08-11T15:10:01.790532696Z"} 4 | {"host":"bishopfox.com","ip":"172.67.83.42","port":{"Port":80,"Protocol":0,"TLS":false},"timestamp":"2023-08-11T15:10:01.790532696Z"} 5 | {"host":"scanme.nmap.org","ip":"45.33.32.156","port":{"Port":22,"Protocol":0,"TLS":false},"timestamp":"2023-08-11T15:10:01.790872133Z"} 6 | -------------------------------------------------------------------------------- /testdata/notxml.txt: -------------------------------------------------------------------------------- 1 | not xml 2 | -------------------------------------------------------------------------------- /testdata/np.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "ip": "45.33.32.156", 4 | "hostname": "scanme.nmap.org", 5 | "tcp_ports": { 6 | "22": { 7 | "name": "ssh", 8 | "product": "OpenSSH", 9 | "version": "6.6.1p1 Ubuntu 2ubuntu2.13", 10 | "extra_info": "Ubuntu Linux; protocol 2.0" 11 | }, 12 | "31337": { 13 | "name": "Elite" 14 | }, 15 | "80": { 16 | "name": "http", 17 | "product": "Apache httpd", 18 | "version": "2.4.7", 19 | "extra_info": "(Ubuntu)" 20 | }, 21 | "9929": { 22 | "name": "nping-echo", 23 | "product": "Nping echo" 24 | } 25 | } 26 | }, 27 | { 28 | "ip": "159.223.119.162", 29 | "hostname": "bishopfox.com", 30 | "tcp_ports": { 31 | "443": { 32 | "name": "https" 33 | }, 34 | "80": { 35 | "name": "http" 36 | } 37 | } 38 | } 39 | ] 40 | -------------------------------------------------------------------------------- /testdata/sub-ips-fast.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 |
39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 |
81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 |
95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 |
109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 |
123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 |
137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 |
151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 |
165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 |
179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 |
193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 |
207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 |
221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 |
235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 |
249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 |
263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 |
277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 |
291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 |
305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 |
319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 |
333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 |
347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 |
360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 |
373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 |
387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 |
401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | -------------------------------------------------------------------------------- /testdata/subdomain-ips.txt: -------------------------------------------------------------------------------- 1 | 3.208.151.108 2 | 3.225.118.150 3 | 52.72.203.239 4 | 3.213.253.249 5 | 23.22.148.94 6 | 18.211.176.235 7 | 52.3.111.54 8 | 52.87.30.71 9 | 44.195.98.204 10 | 54.157.96.85 11 | 54.82.194.95 12 | 50.16.222.14 13 | 34.202.242.48 14 | 35.168.92.30 15 | 3.230.70.74 16 | 34.197.129.44 17 | 34.200.14.249 18 | 3.209.200.17 19 | 52.20.247.127 20 | 34.225.79.76 21 | 34.196.109.14 22 | 18.210.164.205 23 | 107.23.196.127 24 | 3.229.105.92 25 | 159.127.198.158 26 | 75.101.157.144 27 | 3.222.15.36 28 | 18.207.74.113 29 | 34.225.117.206 30 | 54.161.184.58 31 | 54.161.21.39 32 | 50.16.215.175 33 | 174.129.61.172 34 | 3.222.21.127 35 | -------------------------------------------------------------------------------- /testdata/subdomains.txt: -------------------------------------------------------------------------------- 1 | account-public-service-prod.ol.epicgames.com 2 | account-public-service-prod.ak.epicgames.com 3 | approval-bot.it.epicgames.com 4 | accounts.epicgames-stage.ol.epicgames.com 5 | affiliate-public-service-prod.ol.epicgames.com 6 | account-public-service-prod03.ol.epicgames.com 7 | approval-bot.stage.it.epicgames.com 8 | accts.epicgames.com 9 | artifact-public-service-stage.aeee.dev.use1a.on.epicgames.com 10 | accounts.launcher-ci.ol.epicgames.com 11 | -------------------------------------------------------------------------------- /testdata/subs-dnsx.json: -------------------------------------------------------------------------------- 1 | {"host":"account-public-service-prod03.ol.epicgames.com","resolver":["1.1.1.1:53"],"a":["23.22.119.195","54.173.38.231","34.193.246.121","18.210.105.155","52.203.213.25","3.218.128.94","3.216.245.130","34.197.137.55"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.245227807-06:00"} 2 | {"host":"account-public-service-prod.ak.epicgames.com","resolver":["1.0.0.1:53"],"a":["52.87.30.71","52.72.203.239","23.22.148.94","18.211.176.235","3.213.253.249","52.3.111.54"],"cname":["account-service-prod03-pub-ak-1731030959.us-east-1.elb.amazonaws.com"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.246790618-06:00"} 3 | {"host":"account-public-service-prod.ol.epicgames.com","resolver":["8.8.8.8:53"],"a":["3.229.14.0","54.85.213.211","52.3.176.158","34.197.137.55","54.156.140.64","52.3.195.52","54.152.80.223","34.193.246.121"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.256693343-06:00"} 4 | {"host":"affiliate-public-service-prod.ol.epicgames.com","resolver":["8.8.8.8:53"],"a":["107.23.196.127","3.229.105.92"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.277656122-06:00"} 5 | {"host":"accounts.launcher-ci.ol.epicgames.com","resolver":["8.8.4.4:53"],"a":["3.222.21.127","174.129.61.172"],"cname":["accountportalv2-website-ci-lc-p-175953473.us-east-1.elb.amazonaws.com"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.280834491-06:00"} 6 | {"host":"accts.epicgames.com","resolver":["8.8.4.4:53"],"a":["159.127.198.158"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.28991893-06:00"} 7 | {"host":"approval-bot.it.epicgames.com","resolver":["8.8.8.8:53"],"a":["34.225.117.206"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.294781206-06:00"} 8 | {"host":"artifact-public-service-stage.aeee.dev.use1a.on.epicgames.com","resolver":["1.0.0.1:53"],"a":["54.161.184.58","50.16.215.175","54.161.21.39"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.347508156-06:00"} 9 | {"host":"accounts.epicgames-stage.ol.epicgames.com","resolver":["1.0.0.1:53"],"a":["18.207.74.113","3.222.15.36"],"cname":["accountportalv2-web-stg-a-2123378841.us-east-1.elb.amazonaws.com"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.35127031-06:00"} 10 | {"host":"approval-bot.stage.it.epicgames.com","resolver":["1.1.1.1:53"],"a":["75.101.157.144"],"status_code":"NOERROR","timestamp":"2022-05-10T10:54:41.365771031-06:00"} 11 | -------------------------------------------------------------------------------- /testdata/targets.txt: -------------------------------------------------------------------------------- 1 | north-america.pool.ntp.org 2 | scanme.nmap.org 3 | bishopfox.com 4 | --------------------------------------------------------------------------------