impr winpeas networking checks
This commit is contained in:
parent
c9282b4bdb
commit
1e72dbeb76
@ -469,6 +469,13 @@ namespace winPEAS.Checks
|
|||||||
Beaprint.PrintException($" Error: {connectivityInfo.HttpsError}");
|
Beaprint.PrintException($" Error: {connectivityInfo.HttpsError}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTPS By Domain Name
|
||||||
|
Beaprint.AnsiPrint($" HTTPS (443) Access by Domain Name: {(connectivityInfo.LambdaAccess ? "Accessible" : "Not Accessible")}", colorsBool);
|
||||||
|
if (!string.IsNullOrEmpty(connectivityInfo.LambdaError))
|
||||||
|
{
|
||||||
|
Beaprint.PrintException($" Error: {connectivityInfo.LambdaError}");
|
||||||
|
}
|
||||||
|
|
||||||
// DNS Access
|
// DNS Access
|
||||||
Beaprint.AnsiPrint($" DNS (53) Access: {(connectivityInfo.DnsAccess ? "Accessible" : "Not Accessible")}", colorsBool);
|
Beaprint.AnsiPrint($" DNS (53) Access: {(connectivityInfo.DnsAccess ? "Accessible" : "Not Accessible")}", colorsBool);
|
||||||
if (!string.IsNullOrEmpty(connectivityInfo.DnsError))
|
if (!string.IsNullOrEmpty(connectivityInfo.DnsError))
|
||||||
|
@ -50,7 +50,7 @@ namespace winPEAS.Info.NetworkInfo
|
|||||||
private const string LAMBDA_URL =
|
private const string LAMBDA_URL =
|
||||||
"https://2e6ppt7izvuv66qmx2r3et2ufi0mxwqs.lambda-url.us-east-1.on.aws/";
|
"https://2e6ppt7izvuv66qmx2r3et2ufi0mxwqs.lambda-url.us-east-1.on.aws/";
|
||||||
|
|
||||||
// Shared HttpClient (recommended pattern)
|
// Shared HttpClient (kept for HTTP & Lambda checks)
|
||||||
private static readonly HttpClient http = new HttpClient
|
private static readonly HttpClient http = new HttpClient
|
||||||
{
|
{
|
||||||
Timeout = TimeSpan.FromMilliseconds(HTTP_TIMEOUT_MS)
|
Timeout = TimeSpan.FromMilliseconds(HTTP_TIMEOUT_MS)
|
||||||
@ -60,18 +60,49 @@ namespace winPEAS.Info.NetworkInfo
|
|||||||
private static bool TryHttpAccess(string ip, out string error) =>
|
private static bool TryHttpAccess(string ip, out string error) =>
|
||||||
TryWebRequest($"http://{ip}", out error);
|
TryWebRequest($"http://{ip}", out error);
|
||||||
|
|
||||||
private static bool TryHttpsAccess(string ip, out string error) =>
|
// **NEW IMPLEMENTATION** – plain TCP connect on port 443
|
||||||
TryWebRequest($"https://{ip}", out error);
|
private static bool TryHttpsAccess(string ip, out string error)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var client = new TcpClient();
|
||||||
|
|
||||||
|
// Start async connect and wait up to the timeout
|
||||||
|
var connectTask = client.ConnectAsync(ip, 443);
|
||||||
|
bool completed = connectTask.Wait(HTTP_TIMEOUT_MS);
|
||||||
|
|
||||||
|
if (!completed)
|
||||||
|
{
|
||||||
|
error = "TCP connect timed out";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (client.Connected)
|
||||||
|
{
|
||||||
|
error = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
error = "TCP connection failed";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
error = ex.Message;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static bool TryWebRequest(string url, out string error)
|
private static bool TryWebRequest(string url, out string error)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var cts = new CancellationTokenSource(
|
using var cts =
|
||||||
TimeSpan.FromMilliseconds(HTTP_TIMEOUT_MS));
|
new CancellationTokenSource(TimeSpan.FromMilliseconds(HTTP_TIMEOUT_MS));
|
||||||
http.GetAsync(url, cts.Token).GetAwaiter().GetResult();
|
http.GetAsync(url, cts.Token).GetAwaiter().GetResult();
|
||||||
error = null;
|
|
||||||
return true; // any response = connectivity
|
error = null; // any HTTP response == connectivity
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -84,8 +115,8 @@ namespace winPEAS.Info.NetworkInfo
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var cts = new CancellationTokenSource(
|
using var cts =
|
||||||
TimeSpan.FromMilliseconds(HTTP_TIMEOUT_MS));
|
new CancellationTokenSource(TimeSpan.FromMilliseconds(HTTP_TIMEOUT_MS));
|
||||||
|
|
||||||
var req = new HttpRequestMessage(HttpMethod.Get, LAMBDA_URL);
|
var req = new HttpRequestMessage(HttpMethod.Get, LAMBDA_URL);
|
||||||
req.Headers.UserAgent.ParseAdd("winpeas");
|
req.Headers.UserAgent.ParseAdd("winpeas");
|
||||||
@ -172,7 +203,7 @@ namespace winPEAS.Info.NetworkInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HTTPS
|
// HTTPS (raw TCP 443)
|
||||||
if (!info.HttpsAccess)
|
if (!info.HttpsAccess)
|
||||||
{
|
{
|
||||||
string httpsErr;
|
string httpsErr;
|
||||||
|
Loading…
Reference in New Issue
Block a user