我可以将批处理文件的答案发送到二进制文件吗 [英] can i send answer to binary file with batch file

查看:91
本文介绍了我可以将批处理文件的答案发送到二进制文件吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有二进制文件,并使用以下代码使用批处理文件运行该文件:


I have Binary file and run that with a batch file with this code :

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

然后二进制文件("login.exe")等待插入密码(从标准输入中询问密码)
而且我想使用批处理文件中的密码发送带有echo或sendkey的密码

then binar file ("login.exe") waiting for insert password (ask password from standard input)
And i want to send password with echo or sendkey to that using from batch file

我正在使用此代码

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

我该怎么办?那有可能吗?

what can i do ? that is possible ?

推荐答案

如果要与其他应用程序中打开的窗口进行交互,这是一个很好的起点

this is a good point to start if you want to interact with open windows from another application

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();

}
}

您可以找到该窗口是否聚焦并激活了键盘记录器,但这是恶意的...

you can find if the window that on focus, and active a keylogger but this is malicious...

这篇关于我可以将批处理文件的答案发送到二进制文件吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆