can i send answer to binary file with batch file

女生的网名这么多〃 提交于 2020-01-05 13:10:21

问题



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

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

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

I'm using from this code

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

what can i do ? that is possible ?


回答1:


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...



来源:https://stackoverflow.com/questions/31084208/can-i-send-answer-to-binary-file-with-batch-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!