Last active
March 6, 2023 13:10
-
-
Save imba-tjd/8378cf0aba60ff616519a1a048216913 to your computer and use it in GitHub Desktop.
快速打开我的小米的FTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// csc mi-ftp-open.cs /o /t:winexe | |
using System.Net.Sockets; | |
using System.Threading.Tasks; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
class Program | |
{ | |
static readonly string[] IPList = { | |
"192.168.0.100", "192.168.0.101", "192.168.0.102", "192.168.0.103", "192.168.0.104", | |
"192.168.0.105", "192.168.0.106", "192.168.0.107", "192.168.0.108", "192.168.0.109", | |
}; | |
[DllImport("user32")] | |
static extern void MessageBox(nint hWnd, string text, string caption, uint type); | |
static void Main() | |
{ | |
var tasks = new Task[IPList.Length]; | |
for (int i = 0; i < IPList.Length; i++) | |
tasks[i] = new TcpClient(){ SendTimeout = 200 }.ConnectAsync(IPList[i], 2121); | |
int ndx = Task.WaitAny(tasks); | |
if (tasks[ndx].IsFaulted) | |
MessageBox(0, "Undetected", null, 0); | |
else | |
Process.Start("explorer", string.Format("ftp://{0}:2121/download", IPList[ndx])); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment