我可以用批处理文件发送二进制文件的答案吗?

时间:2015-06-27 01:20:14

标签: batch-file sendkeys


我有二进制文件并使用此代码运行批处理文件:

call "login.exe" site sample.com -user myusername

然后二进制文件(“login.exe”)等待插入密码(从标准输入中询问密码)
我想使用批处理文件

发送带有echo或sendkey的密码

我正在使用此代码

call run_binary.bat
timeout /t 1
%SendKeys% "password{ENTER}"

我该怎么办?那可能吗?

1 个答案:

答案 0 :(得分:-1)

如果您想与来自其他应用程序的打开窗口进行交互,这是一个很好的开始

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace keystroke
{
    public class handler
    {
        public const int WM_SYSCOMMAND = 0x0112;
        public const int SC_CLOSE = 0xF060;

    [DllImport("user32.dll")]
    public static extern int FindWindow(
        string lpClassName, 
        string lpWindowName
    );

    [DllImport("user32.dll")]
    public static extern int SetForegroundWindow(
        int hWnd 
    );

    private const int GWL_EXSTYLE = (-20);
    private const int WS_EX_TOOLWINDOW = 0x80;
    private const int WS_EX_APPWINDOW = 0x40000;

    public const int GW_HWNDFIRST = 0;
    public const int GW_HWNDLAST = 1;
    public const int GW_HWNDNEXT = 2;
    public const int GW_HWNDPREV = 3;
    public const int GW_OWNER = 4;
    public const int GW_CHILD = 5;

    public delegate int EnumWindowsProcDelegate(int hWnd, int lParam);

    [DllImport("User32.Dll")]
    public static extern void GetWindowText(int h, StringBuilder s, int nMaxCount);

    [DllImport("user32", EntryPoint = "GetWindowLongA")]
    public static extern int GetWindowLongPtr(int hwnd, int nIndex);

    [DllImport("user32")]
    public static extern int GetParent(int hwnd);

    [DllImport("user32")]
    public static extern int GetWindow(int hwnd, int wCmd);

    [DllImport("user32")]
    public static extern int IsWindowVisible(int hwnd);

    [DllImport("user32")]
    public static extern int GetDesktopWindow();

}
}

你可以找到关注焦点的窗口,并激活一个键盘记录器,但这是恶意的......