diff --git a/nselib/afp.lua b/nselib/afp.lua index 4ee8f5c11..99f1efc69 100644 --- a/nselib/afp.lua +++ b/nselib/afp.lua @@ -8,8 +8,9 @@ -- -- --- Version 0.1 +-- Version 0.2 -- Created 01/03/2010 - v0.1 - created by Patrik Karlsson +-- Revised 01/20/2010 - v0.2 - updated all bitmaps to hex for better readability module(... or "afp",package.seeall) @@ -39,61 +40,61 @@ COMMAND = { } USER_BITMAP = { - UserId = 1, - PrimaryGroupId = 2, - UUID = 4 + UserId = 0x01, + PrimaryGroupId = 0x2, + UUID = 0x4 } VOL_BITMAP = { - Attributes = 1, - Signature = 2, - CreationDate = 4, - ModificationDate = 8, - BackupDate = 16, - ID = 32, - BytesFree = 64, - BytesTotal = 128, - Name = 256, - ExtendedBytesFree = 512, - ExtendedBytesTotal = 1024, - BlockSize = 2048 + Attributes = 0x1, + Signature = 0x2, + CreationDate = 0x4, + ModificationDate = 0x8, + BackupDate = 0x10, + ID = 0x20, + BytesFree = 0x40, + BytesTotal = 0x80, + Name = 0x100, + ExtendedBytesFree = 0x200, + ExtendedBytesTotal = 0x400, + BlockSize = 0x800 } FILE_BITMAP = { - Attributes = 1, - DID = 2, - CreationDate = 4, - ModificationDate = 8, - BackupDate = 16, - FinderInfo = 32, - LongName = 64, - ShortName = 128, - FileId = 256, - DataForkSize = 512, - ResourceForkSize = 1024, - ExtendedDataForkSize = 2048, - LaunchLimit = 4096, - UTF8Name = 8192, - ExtendedResourceForkSize = 16384, - UnixPrivileges = 32768 + Attributes = 0x1, + DID = 0x2, + CreationDate = 0x4, + ModificationDate = 0x8, + BackupDate = 0x10, + FinderInfo = 0x20, + LongName = 0x40, + ShortName = 0x80, + FileId = 0x100, + DataForkSize = 0x200, + ResourceForkSize = 0x400, + ExtendedDataForkSize = 0x800, + LaunchLimit = 0x1000, + UTF8Name = 0x2000, + ExtendedResourceForkSize = 0x4000, + UnixPrivileges = 0x8000 } DIR_BITMAP = { - Attributes = 1, - DID = 2, - CreationDate = 4, - ModificationDate = 8, - BackupDate = 16, - FinderInfo = 32, - LongName = 64, - ShortName = 128, - FileId = 256, - OffspringCount = 512, - OwnerId = 1024, - GroupId = 2048, - AccessRights = 4096, - UTF8Name = 8192, - UnixPrivileges = 32768 + Attributes = 0x1, + DID = 0x2, + CreationDate = 0x4, + ModificationDate = 0x8, + BackupDate = 0x10, + FinderInfo = 0x20, + LongName = 0x40, + ShortName = 0x80, + FileId = 0x100, + OffspringCount = 0x200, + OwnerId = 0x400, + GroupId = 0x800, + AccessRights = 0x1000, + UTF8Name = 0x2000, + UnixPrivileges = 0x8000 } PATH_TYPE = { @@ -102,31 +103,31 @@ PATH_TYPE = { } ACCESS_MODE = { - Read = 1, - Write = 2, - DenyRead = 16, - DenyWrite = 32 + Read = 0x1, + Write = 0x2, + DenyRead = 0x10, + DenyWrite = 0x20 } ACLS = { - OwnerSearch = 1, - OwnerRead = 2, - OwnerWrite = 4, + OwnerSearch = 0x1, + OwnerRead = 0x2, + OwnerWrite = 0x4, - GroupSearch = 256, - GroupRead = 512, - GroupWrite = 1024, + GroupSearch = 0x100, + GroupRead = 0x200, + GroupWrite = 0x400, - EveryoneSearch = 65536, - EveryoneRead = 131072, - EveryoneWrite = 262144, + EveryoneSearch = 0x10000, + EveryoneRead = 0x20000, + EveryoneWrite = 0x40000, - UserSearch = 1048576, - UserRead = 2097152, - UserWrite = 4194304, + UserSearch = 0x100000, + UserRead = 0x200000, + UserWrite = 0x400000, - BlankAccess = 268435456, - UserIsOwner = 2147483648 + BlankAccess = 0x10000000, + UserIsOwner = 0x80000000 } -- Each packet contains a sequential request id diff --git a/scripts/afp-showmount.nse b/scripts/afp-showmount.nse index a2f5703aa..2695893fb 100644 --- a/scripts/afp-showmount.nse +++ b/scripts/afp-showmount.nse @@ -17,9 +17,10 @@ description = [[ Shows AFP shares and ACLs ]] -- | User: Search,Read -- |_ Options: IsOwner --- Version 0.1 +-- Version 0.3 -- Created 01/03/2010 - v0.1 - created by Patrik Karlsson -- Revised 01/13/2010 - v0.2 - Fixed a bug where a single share wouldn't show due to formatting issues +-- Revised 01/20/2010 - v0.3 - removed superflous functions author = "Patrik Karlsson" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" @@ -31,36 +32,6 @@ require 'afp' portrule = shortport.portnumber(548, "tcp") ---- Converts a group bitmask of Search, Read and Write to string --- eg. WRS, -RS, W-S, etc .. --- --- @param acls number containing bitmasked acls --- @return string of ACLS -function acl_group_to_string( acls ) - - local acl_string = "" - - if bit.band( acls, afp.ACLS.OwnerSearch ) == afp.ACLS.OwnerSearch then - acl_string = "S" - else - acl_string = "-" - end - - if bit.band( acls, afp.ACLS.OwnerRead ) == afp.ACLS.OwnerRead then - acl_string = "R" .. acl_string - else - acl_string = "-" .. acl_string - end - - if bit.band( acls, afp.ACLS.OwnerWrite ) == afp.ACLS.OwnerWrite then - acl_string = "W" .. acl_string - else - acl_string = "-" .. acl_string - end - - return acl_string -end - --- Converts a group bitmask of Search, Read and Write to table -- -- @param acls number containing bitmasked acls @@ -84,23 +55,6 @@ function acl_group_to_long_string(acls) return acl_table end ---- Converts a numeric acl to string --- --- @param acls number containig acls as recieved from fp_get_file_dir_parms --- @return string of ACLs -function acls_to_string( acls ) - - local owner = acl_group_to_string( bit.band( acls, 255 ) ) - local group = acl_group_to_string( bit.band( bit.rshift(acls, 8), 255 ) ) - local everyone = acl_group_to_string( bit.band( bit.rshift(acls, 16), 255 ) ) - local user = acl_group_to_string( bit.band( bit.rshift(acls, 24), 255 ) ) - - local blank = bit.band( acls, afp.ACLS.BlankAccess ) == afp.ACLS.BlankAccess and "B" or "-" - local isowner = bit.band( acls, afp.ACLS.UserIsOwner ) == afp.ACLS.UserIsOwner and "O" or "-" - - return string.format("Owner: %s; Group: %s; Everyone: %s; User: %s; Options: %s%s", owner, group, everyone, user, blank, isowner ) - -end --- Converts a numeric acl to string --