考虑在.txt文件中包含以下字符串
127.0.0.1
127.0.0.2
127.0.0.3或者在数组中:
{"127.0.0.1","127.0.0.2","127.0.0.3"}并考虑将以下字符串放入不同的.txt文件:
curl -sS -L https://github.com/vulmon/Vulmap/archive/master.tar.gz -o vulmap.tgz && echo y | sshpass -p 'ubuntu' scp -q ./vulmap.tgz ubuntu@192.168.74.133: && echo y | sshpass -p '{password}' ssh {username}@{ip} "mkdir -p ~/tmp-vulmap && cd ~/tmp-vulmap && tar -xzf ../vulmap.tgz && rm ../vulmap.tgz && cd ./Vulmap-master/Vulmap-Linux && python3 vulmap-linux.py"curl -sS -L https://github.com/D0cT0r-inf0s3c/Praus/archive/master.tar.gz -o praus.tgz && echo y | sshpass -p 'ubuntu' scp -q ./praus.tgz ubuntu@192.168.74.133: && echo y | sshpass -p '{password}' ssh {username}@{ip} "mkdir -p ~/tmp-praus && cd ~/tmp-praus && tar -xzf ../praus.tgz && rm ../praus.tgz && cd ./Praus-master && (echo; echo 2; echo 1; echo 8; echo; echo 3; echo; echo 1;) | sudo bash praus.sh"curl -L https://github.com/speed47/spectre-meltdown-checker/archive/master.tar.gz -o spectre-meltdown-checker.tgz && sshpass -p '{password}' scp -q ./spectre-meltdown-checker.tgz {username}@{ip}: && sshpass -p '{password}' ssh {username}@{password} "mkdir -p ~/tmp-BeRoot && cd ~/tmp-spectre-meltdown-checker && tar -xzf ../spectre-meltdown-checker.tgz && rm ../spectre-meltdown-checker.tgz && cd ./spectre-meltdown-checker-master && ./spectre-meltdown-checker.sh"是否有可能用IP替换字符串{ip}?对于用户名和密码,用户输入的参数将被解析。如果{ip}能够工作,那么我也会找到这两个。
条件:
发布于 2022-05-06 09:57:23
我已经找到了解决这个问题的办法:
public class Test
{
public static void Main()
{
string replace = @"{ip}";
//Hosts & programs
string whosts = @"/hosts/windows.txt";
string lhosts = @"/hosts/linux.txt";
string defaultprofile = "programs.config";
//IP Locations
string llocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + lhosts;
string wlocation = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + whosts;
//string[] ips = { "127.0.0.1", "127.0.0.2", "127.0.0.3", "127.0.0.4", "127.0.0.5", "127.0.0.6", "127.0.0.7", "127.0.0.8", "127.0.0.9", "127.0.0.10", "127.0.0.0" };
//Read winips and linips
List<string> winhosts = File.ReadAllLines(wlocation).ToList();
List<string> linhosts = File.ReadAllLines(wlocation).ToList();
ParallelOptions? options = new() { MaxDegreeOfParallelism = Environment.ProcessorCount, CancellationToken = CancellationToken.None };
//Check if windows.txt contains any hosts
if (winhosts.Any())
{
string[] lines = File.ReadAllLines(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"/example/" + defaultprofile);
List<string> winprograms = lines.SkipWhile(x => x != "WINVULNSCAN:") // skips everything before
.Skip(1) // and <rs:data> itself
.TakeWhile(x => x != "LINVULNSCAN:") // and take up to </rs:data>
.ToList(); //Converts it to a List
Parallel.ForEach(winhosts, host =>
{
Parallel.ForEach(winprograms, line =>
{
string? result = line.Replace(replace, host);
Console.WriteLine(result + Environment.NewLine);
});
});
}
//check if linux.txt contains any hosts
if (linhosts.Any())
{
string[] lines = File.ReadAllLines(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"/example/" + defaultprofile);
List<string> linprograms = lines.SkipWhile(x => x != "LINVULNSCAN:") // skips everything before
.Skip(1) // and <rs:data> itself
.TakeWhile(x => x != "OTHERVULNSCAN:") // and take up to </rs:data>
.ToList(); //Converts it to a List
Parallel.ForEach(linhosts, host =>
{
Parallel.ForEach(linprograms, line =>
{
string? result = line.Replace(replace, host);
Console.WriteLine(result + Environment.NewLine);
});
});
}
}
}https://stackoverflow.com/questions/72109303
复制相似问题