⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smb_nt.inc

📁 漏洞扫描源码,可以扫描linux,windows,交换机路由器
💻 INC
📖 第 1 页 / 共 5 页
字号:
    #     display("writeable by ", sid, "\n");    #	  display(mask & WRITE, "\n");		 if((sid != ADMIN_SID) &&  	    (sid != LOCAL_SYSTEM_SID) && 	    (sid != CREATOR_OWNER_SID))	 {	   #display("sid != ", CREATOR_OWNER_SID, "\n");	   #display(mask, "\n");	   return(TRUE);	 }      }  s = s + z; }  return(FALSE);}#---------------------------------------------------------------------## Get the security descriptor for a key                               ##---------------------------------------------------------------------#function registry_get_key_security(soc, uid, tid, pipe, reply){ local_var magic, req, r, tid_low, tid_high, uid_low, uid_high, pipe_low, pipe_high;  tid_low = tid % 256; tid_high = tid / 256;  uid_low = uid % 256; uid_high = uid / 256;  pipe_low = pipe % 256; pipe_high = pipe / 256;  req = raw_string(0x00, 0x00, 		  0x00, 0x90, 0xFF, 0x53, 0x4D, 0x42, 0x25, 0x00,		  0x00, 0x00, 0x00, 0x18, 0x03, 0x80, 0x00, 0x83,		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,		  0x00, 0x00, tid_low, tid_high, 0x00, 0x28, uid_low, uid_high,		  g_mlo, g_mhi, 0x10, 0x00, 0x00, 0x3C, 0x00, 0x00,		  0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54,		  0x00, 0x3C, 0x00, 0x54, 0x00, 0x02, 0x00, 0x26,		  0x00, pipe_low, pipe_high, 0x4D, 0x00, 0x00, 0x5C, 0x00,		  0x50, 0x00, 0x49, 0x00, 0x50, 0x00, 0x45, 0x00,		  0x5C, 0x00, 0x00, 0x00, 0xEE, 0xD5, 0x05, 0x00,		  0x00, 0x03, 0x10, 0x00, 0x00, 0x00, 0x3C, 0x00,		  0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x24, 0x00,		  0x00, 0x00, 0x00, 0x00, 0x0c, 0x00); if(strlen(reply) < 104)return(FALSE);  magic = raw_string(ord(reply[84]));		   for(i=1;i<20;i=i+1) {  magic = magic + raw_string(ord(reply[84+i])); }  req = req + magic + raw_string(0x04) + crap(data:raw_string(0), length:15);  send(socket:soc, data:req); r = smb_recv(socket:soc, length:65535);   len1 =  ord(r[strlen(r) - 12]); len2 = ord(r[strlen(r) - 11]); len3 = ord(r[strlen(r) - 10]); len4 = ord(r[strlen(r) - 9]); req = raw_string(0x00, 0x00, 		  0x00, 0x9C, 0xFF, 0x53, 0x4D, 0x42, 0x25, 0x00,		  0x00, 0x00, 0x00, 0x18, 0x03, 0x80, 0x00, 0x83,		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,		  0x00, 0x00, tid_low, tid_high, 0x00, 0x28, uid_low, uid_high,		  g_mlo, g_mhi, 0x10, 0x00, 0x00, 0x48, 0x00, 0x00,		  0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54,		  0x00, 0x48, 0x00, 0x54, 0x00, 0x02, 0x00, 0x26,		  0x00, pipe_low, pipe_high, 0x59, 0x00, 0x00, 0x5C, 0x00,		  0x50, 0x00, 0x49, 0x00, 0x50, 0x00, 0x45, 0x00,		  0x5C, 0x00, 0x00, 0x00, 0xEE, 0xD5, 0x05, 0x00,		  0x00, 0x03, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00,		  0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x30, 0x00,		  0x00, 0x00, 0x00, 0x00, 0x0c, 0x00);		    req = req + magic + raw_string(0x04, 0x00, 0x00, 0x00, 0x38, 0x8d,       0x07, 0x00, len1, len2, len3, len4, 0x00, 0x00,       0x00, 0x00, len1, len2, len3, len4, 0x00, 0x00,       0x00, 0x00, 0x00, 0x00, 0x00, 0x00);		  		 send(socket:soc, data:req); r = smb_recv(socket:soc, length:65535); if(strlen(r) < 150)return(NULL); return(r);} #---------------------------------------------------------------------## returns 'TRUE' if <key> exists				      ##---------------------------------------------------------------------#function registry_key_exists(key){ local_var name, domain, _smb_port, login, pass, soc, r, uid, tid, pipe, ret, prot; local_var magic, flag, i; name =  kb_smb_name();if(!name)exit(0);domain = kb_smb_domain();_smb_port = kb_smb_transport();if(!_smb_port)exit(0);if(!get_port_state(_smb_port))return(FALSE);login = kb_smb_login();pass  = kb_smb_password();if(!login)login = "";if(!pass) pass = "";	  soc = open_sock_tcp(_smb_port);if ( ! soc ) return NULL;## Request the session# r = smb_session_request(soc:soc,  remote:name);if(!r)return(FALSE);## Negociate the protocol#prot = smb_neg_prot(soc:soc);if(!prot)return(FALSE);## Set up our session#r = smb_session_setup(soc:soc, login:login, password:pass, domain:domain, prot:prot);if(!r)return(FALSE);# and extract our uiduid = session_extract_uid(reply:r);## Connect to the remote IPC and extract the TID# we are attributed#      r = smb_tconx(soc:soc, name:name, uid:uid, share:"IPC$");# and extract our tree idtid = tconx_extract_tid(reply:r);if(!tid)return(NULL);## Create a pipe to \winreg#r = smbntcreatex(soc:soc, uid:uid, tid:tid, name:"\winreg");if(!r)return(NULL);# and extract its IDpipe = smbntcreatex_extract_pipe(reply:r);## Setup things#r = pipe_accessible_registry(soc:soc, uid:uid, tid:tid, pipe:pipe);if(!r)return(FALSE);r = registry_open_hklm(soc:soc, uid:uid, tid:tid, pipe:pipe);r2 = registry_get_key(soc:soc, uid:uid, tid:tid, pipe:pipe, key:key, reply:r);close(soc);registry_close(soc:soc, uid:uid, tid:tid, pipe:pipe, reply:r2);registry_close(soc:soc, uid:uid, tid:tid, pipe:pipe, reply:r);if ( ! r2 && strlen(r2) < 104) return NULL;flag = 0;for(i=1;i<20;i=i+1) {  if ( ord(r2[84+i]) != 0 ) flag = 1; }if ( flag ) return TRUE;else return NULL;}		 #---------------------------------------------------------------------## returns 'TRUE' if <key> is writeable				      ##---------------------------------------------------------------------#function registry_get_acl(key){ local_var name, domain, _smb_port, login, pass, soc, r, uid, tid, pipe, ret, prot; name =  kb_smb_name();if(!name)exit(0);domain = kb_smb_domain();_smb_port = kb_smb_transport();if(!_smb_port)exit(0);if(!get_port_state(_smb_port))return(FALSE);login = kb_smb_login();pass  = kb_smb_password();if(!login)login = "";if(!pass) pass = "";	  soc = open_sock_tcp(_smb_port);if ( ! soc ) return NULL;## Request the session# r = smb_session_request(soc:soc,  remote:name);if(!r)return(FALSE);## Negociate the protocol#prot = smb_neg_prot(soc:soc);if(!prot)return(FALSE);## Set up our session#r = smb_session_setup(soc:soc, login:login, password:pass, domain:domain, prot:prot);if(!r)return(FALSE);# and extract our uiduid = session_extract_uid(reply:r);## Connect to the remote IPC and extract the TID# we are attributed#      r = smb_tconx(soc:soc, name:name, uid:uid, share:"IPC$");# and extract our tree idtid = tconx_extract_tid(reply:r);if(!tid)return(NULL);## Create a pipe to \winreg#r = smbntcreatex(soc:soc, uid:uid, tid:tid, name:"\winreg");if(!r)return(NULL);# and extract its IDpipe = smbntcreatex_extract_pipe(reply:r);## Setup things#r = pipe_accessible_registry(soc:soc, uid:uid, tid:tid, pipe:pipe);if(!r)return(FALSE);r = registry_open_hklm(soc:soc, uid:uid, tid:tid, pipe:pipe);if(strlen(key)) r2 = registry_get_key(soc:soc, uid:uid, tid:tid, pipe:pipe, key:key, reply:r);else  r2 = r;if(r2) { r3 =  registry_get_key_security(soc:soc, uid:uid, tid:tid, pipe:pipe, reply:r2); registry_close(soc:soc, uid:uid, tid:tid, pipe:pipe, reply:r2); if ( strlen(key) )  registry_close(soc:soc, uid:uid, tid:tid, pipe:pipe, reply:r); close(soc);  if(strlen(r3) < 100)return(NULL); return(r3); }return(NULL);}#---------------------------------------------------------------------## Get an item of type reg_sz from the key                             ##---------------------------------------------------------------------#function unicode2(data){ len = strlen(data); ret = raw_string(0, ord(data[0]));  for(i=1;i<len;i=i+1) {  ret = ret + raw_string(0, ord(data[i])); } if(len & 1)ret = ret + raw_string(0x00, 0x00);  else ret = ret + raw_string(0x00, 0x00, 0x00, 0x63); return(ret);}function unicode3(data){ len = strlen(data); ret = raw_string(0, ord(data[0]));  for(i=1;i<len;i=i+1) {  ret = ret + raw_string(0, ord(data[i])); } if(len & 1)ret = ret + raw_string(0x00, 0x00);  else ret = ret + raw_string(0x00, 0x00, 0x00, 0x00); return(ret);}function unicode4(data){ len = strlen(data); ret = raw_string(0, ord(data[0]));  for(i=1;i<len;i=i+1) {  ret = ret + raw_string(ord(data[i]),0); } if(len & 1)ret = ret + raw_string(0x00);  return(ret);}function registry_get_item_sz(soc, uid, tid, pipe, item, reply){ local_var i; item_len = strlen(item) + 1; item_len_lo = item_len % 256; item_len_hi = item_len / 256;  uc2 = unicode2(data:item); len = 188 + strlen(uc2); len_lo = len % 256; len_hi = len / 256;  tid_low = tid % 256; tid_high = tid / 256; uid_low = uid % 256; uid_high = uid / 256; pipe_low = pipe % 256; pipe_high = pipe / 256;  bcc = 121 + strlen(uc2); bcc_lo = bcc % 256; bcc_hi = bcc / 256;  y = 80 + strlen(uc2); y_lo = y % 256; y_hi = y / 256;  z = 104 + strlen(uc2); z_lo = z % 256; z_hi = z / 256; req = raw_string(0x00, 0x00, 		  len_hi, len_lo, 0xFF, 0x53, 0x4D, 0x42, 0x25, 0x00,		  0x00, 0x00, 0x00, 0x18, 0x03, 0x80, 0x1D, 0x83,		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,		  0x00, 0x00, tid_low, tid_high, 0x00, 0x28, uid_low, uid_high,		  g_mlo, g_mhi, 0x10, 0x00, 0x00, z_lo, z_hi, 0x00,		  0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,		  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54,		  0x00, z_lo, z_hi, 0x54, 0x00, 0x02, 0x00, 0x26,		  0x00, pipe_low, pipe_high, bcc_lo, bcc_hi, 0x00, 0x5C, 0x00,		  0x50, 0x00, 0x49, 0x00, 0x50, 0x00, 0x45, 0x00,		  0x5C, 0x00, 0x00, 0x00, 0x00, 0x5C, 0x05, 0x00,		  0x00, 0x03, 0x10, 0x00, 0x00, 0x00, z_lo, z_hi,		  0x00, 0x00, 0x03, 0x00, 0x00, 0x00, y_lo, y_hi,		  0x00, 0x00, 0x00, 0x00, 0x11, 0x00);		   if(strlen(reply) < 104)return(FALSE); magic = raw_string(ord(reply[84])); for(i=1;i<20;i=i+1) {  magic = magic + raw_string(ord(reply[84+i])); } x = 2 + strlen(item) + strlen(item); x_lo = x % 256; x_hi = x / 256;   y = y + 3; y_lo = y % 256; y_hi = y / 256;   req = req + magic + raw_string(x_lo, x_hi, 0x0A, 0x02, 0x00, 0xEC,  		0xFD, 0x7F, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00,		0x00, 0x00, item_len_lo, item_len_hi, 0x00)				+ uc2	+ 		raw_string(0x00, 0x34, 0xFF,		0x12, 0x00, 0xEF, 0x10, 0x40, 0x00, 0x18, 0x1E,		0x7c, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0xFF,		0x12, 0x00, 0x00, 0x04, 0x00, 0x00, 0x30, 0xFF,		0x12, 0x00, 0x00, 0x00, 0x00, 0x00);		 send(socket:soc, data:req); req = smb_recv(socket:soc, length:4000);		 return(req);}		  #------------------------------------------------------## Decode the reply from the registry                   ##------------------------------------------------------#function registry_decode_binary(data){ local_var i, o, len, index; len = ord(data[2])*256; len = len + ord(data[3]); if(len < 130)return(NULL);  data_offset = ord(data[52])*256; data_offset = data_offset + ord(data[51]) + 4; data_len = ord(data[data_offset+43]); data_len = data_len * 256; data_len = data_len + ord(data[data_offset+44]); index = data_offset + 48; o = ""; data_len = data_len - 2; for(i=0;i<data_len;i=i+1) {   o = string(o, raw_string(ord(data[index+i]))); } return(o);}function registry_decode_sz(data){ local_var i, o, len, index; len = ord(data[2])*256; len = len + ord(data[3]); if(len < 128)return(NULL);  data_offset = ord(data[52])*256; data_offset = data_offset + ord(data[51]) + 4; data_len = ord(data[data_offset+47]); data_len = data_len * 256 + ord(data[data_offset+46]); data_len = data_len * 256 + ord(data[data_offset+45]); data_len = data_len * 256 + ord(data[data_offset+44]); index = data_offset + 48; o = ""; data_len = data_len - 2;  for(i=0;i<data_len;i=i+2) {   o = string(o, raw_string(ord(data[index+i]))); } return(o);}#---------------------------------------------------------------------##---------------------------------------------------------------------## Get an item of type reg_dword from the key                          ##---------------------------------------------------------------------#function registry_get_item_dword(soc, uid, tid, pipe, item, reply){ local_var item_len, item_len_lo, item_len_hi, uc2, len, len_lo, len_hi, tid_low, tid_high, uid_low, uid_high; local_var pipe_low, pipe_high, bcc, bcc_lo, bcc_hi, y, y_lo, y_hi, z, z_lo, z_hi, req; local_var magic, x, x_lo, x_hi; item_len = strlen(item) + 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -