mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Move arshift from bit.lua to bits.lua
This commit is contained in:
@@ -81,22 +81,6 @@ function rshift(a, b)
|
|||||||
return a >> b
|
return a >> b
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns <code>a</code> arithmetically right-shifted by <code>b</code>
|
|
||||||
-- 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)
|
|
||||||
else
|
|
||||||
return a // (1<<b) + 1
|
|
||||||
end
|
|
||||||
else
|
|
||||||
return a >> b
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns the integer remainder of <code>a</code> divided by <code>b</code>.
|
--- Returns the integer remainder of <code>a</code> divided by <code>b</code>.
|
||||||
--
|
--
|
||||||
-- REPLACEMENT: <code>a % b</code>
|
-- REPLACEMENT: <code>a % b</code>
|
||||||
|
|||||||
@@ -39,6 +39,21 @@ function reverse (n, size)
|
|||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Returns <code>a</code> arithmetically right-shifted by <code>b</code>
|
||||||
|
-- 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)
|
||||||
|
else
|
||||||
|
return a // (1<<b) + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return a >> b
|
||||||
|
end
|
||||||
|
end
|
||||||
do
|
do
|
||||||
local function test8 (a, b)
|
local function test8 (a, b)
|
||||||
local r = reverse(a, 8)
|
local r = reverse(a, 8)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local bit = require "bit"
|
local bits = require "bits"
|
||||||
local bin = require "bin"
|
local bin = require "bin"
|
||||||
local brute = require "brute"
|
local brute = require "brute"
|
||||||
local creds = require "creds"
|
local creds = require "creds"
|
||||||
@@ -198,7 +198,7 @@ local backorifice =
|
|||||||
--calculate next seed
|
--calculate next seed
|
||||||
seed = self:gen_next_seed(seed)
|
seed = self:gen_next_seed(seed)
|
||||||
--calculate encryption key based on 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
|
crypto_byte = data_byte ~ key
|
||||||
output = bin.pack("AC",output,crypto_byte)
|
output = bin.pack("AC",output,crypto_byte)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local bit = require "bit"
|
local bits = require "bits"
|
||||||
local bin = require "bin"
|
local bin = require "bin"
|
||||||
local nmap = require "nmap"
|
local nmap = require "nmap"
|
||||||
local shortport = require "shortport"
|
local shortport = require "shortport"
|
||||||
@@ -202,7 +202,7 @@ local function BOcrypt(data, password, initial_seed )
|
|||||||
--calculate next seed
|
--calculate next seed
|
||||||
seed = gen_next_seed(seed)
|
seed = gen_next_seed(seed)
|
||||||
--calculate encryption key based on 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
|
crypto_byte = data_byte ~ key
|
||||||
output = bin.pack("AC",output,crypto_byte)
|
output = bin.pack("AC",output,crypto_byte)
|
||||||
|
|||||||
Reference in New Issue
Block a user