1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-06 22:49:02 +00:00

Clean up string concatenations

Building a string with var = var .. "something" has miserable time
complexities. This commit cleans up a lot of that in scripts, focusing
on packing of data with bin.pack and concatenations within loops.
Additionally, a few instances were replaced with string.rep
This commit is contained in:
dmiller
2015-02-25 19:58:42 +00:00
parent ddb3905b20
commit 10dce0382c
26 changed files with 174 additions and 205 deletions

View File

@@ -3,6 +3,7 @@ local io = require "io"
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
description = [[
@@ -77,10 +78,9 @@ end
--
local function create_connect_packet( host_ip, port_no, sid )
local connect_data = "(DESCRIPTION=(CONNECT_DATA=(SID=" .. sid .. ")"
connect_data = connect_data .. "(CID=(PROGRAM=)(HOST=__jdbc__)(USER=)))"
connect_data = connect_data .. "(ADDRESS=(PROTOCOL=tcp)(HOST=" .. host_ip .. ")"
connect_data = connect_data .. "(PORT=" .. port_no .. ")))"
local connect_data = string.format(
"(DESCRIPTION=(CONNECT_DATA=(SID=%s)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=)))\z
(ADDRESS=(PROTOCOL=tcp)(HOST=%s)(PORT=%d)))", sid, host_ip, port_no)
local data = bin.pack(">SSSSSSSSSSICCA",
308, -- Version