From 7e5ef7130b41ea95476d22be1511a17cf52f0ac4 Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 28 Aug 2018 15:56:46 +0000 Subject: [PATCH] Move arshift from bit.lua to bits.lua --- nselib/bit.lua | 16 ---------------- nselib/bits.lua | 15 +++++++++++++++ scripts/backorifice-brute.nse | 4 ++-- scripts/backorifice-info.nse | 4 ++-- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/nselib/bit.lua b/nselib/bit.lua index 5b91790c4..63154ae9e 100644 --- a/nselib/bit.lua +++ b/nselib/bit.lua @@ -81,22 +81,6 @@ function rshift(a, b) return a >> b end ---- Returns a arithmetically right-shifted by b --- places. --- @param a Number to perform the shift on. --- @param b Number of shifts. -function arshift(a, b) - if a < 0 then - if a % 2 == 0 then -- even? - return a // (1<> b - end -end - --- Returns the integer remainder of a divided by b. -- -- REPLACEMENT: a % b diff --git a/nselib/bits.lua b/nselib/bits.lua index 7308c6725..6eb4438ec 100644 --- a/nselib/bits.lua +++ b/nselib/bits.lua @@ -39,6 +39,21 @@ function reverse (n, size) return n end +--- Returns a arithmetically right-shifted by b +-- places. +-- @param a Number to perform the shift on. +-- @param b Number of shifts. +function arshift(a, b) + if a < 0 then + if a % 2 == 0 then -- even? + return a // (1<> b + end +end do local function test8 (a, b) local r = reverse(a, 8) diff --git a/scripts/backorifice-brute.nse b/scripts/backorifice-brute.nse index 9b2fc6dda..897c7f949 100644 --- a/scripts/backorifice-brute.nse +++ b/scripts/backorifice-brute.nse @@ -1,4 +1,4 @@ -local bit = require "bit" +local bits = require "bits" local bin = require "bin" local brute = require "brute" local creds = require "creds" @@ -198,7 +198,7 @@ local backorifice = --calculate next seed seed = self:gen_next_seed(seed) --calculate encryption key based on seed - local key = bit.arshift(seed,16) & 0xff + local key = bits.arshift(seed,16) & 0xff crypto_byte = data_byte ~ key output = bin.pack("AC",output,crypto_byte) diff --git a/scripts/backorifice-info.nse b/scripts/backorifice-info.nse index 7d4d5932b..716a77cc3 100644 --- a/scripts/backorifice-info.nse +++ b/scripts/backorifice-info.nse @@ -1,4 +1,4 @@ -local bit = require "bit" +local bits = require "bits" local bin = require "bin" local nmap = require "nmap" local shortport = require "shortport" @@ -202,7 +202,7 @@ local function BOcrypt(data, password, initial_seed ) --calculate next seed seed = gen_next_seed(seed) --calculate encryption key based on seed - local key = bit.arshift(seed,16) & 0xff + local key = bits.arshift(seed,16) & 0xff crypto_byte = data_byte ~ key output = bin.pack("AC",output,crypto_byte)