Compare commits

...

10 Commits

Author SHA1 Message Date
SirBroccoli
7008652029 Merge pull request #462 from jahway603/jahway603-patch-1
Minor URL fix
2025-03-30 19:18:52 +02:00
SirBroccoli
e5239f8c58 Merge pull request #461 from Signum21/master
Handle path access denied
2025-03-30 19:18:34 +02:00
SirBroccoli
b2c03246d2 Merge pull request #459 from gildasio/master
Set grep to show filename that contains passwords
2025-03-30 19:18:13 +02:00
SirBroccoli
f0686d491b Merge pull request #464 from spkal01/master
Rework PEASS url logic for the metasploit module
2025-03-29 21:56:35 +01:00
spkal01
99e8eb7813 Rework PEASS url logic for the metasploit module 2025-03-29 21:45:58 +02:00
Carlos Polop
46193aa0d5 fix 2025-03-20 05:13:54 +01:00
Carlos Polop
62022abc47 impr winpeas 2025-03-20 05:02:34 +01:00
jahway603
d63e737b63 Minor URL fix 2025-03-18 12:33:50 -04:00
Signum21
0b041ad694 Handle path access denied
The program crashes when trying to access a path that is not allowed.
An exampe of this can be found on the latest HackTheBox machine (TheFrizz) where the starting user can't access the path C:\Users
2025-03-16 05:43:48 +01:00
Gildasio Junior
8ea67f3cc2 Set grep to show filename that contains passwords
This way one can identify which file contains the relevant information,
eg:

/var/log/responder/Poisoners-Session.log:2025-02-09 21:12:12,701 - [*] Skipping previously captured cleartext password for donald
/var/log/responder/Responder-Session.log:11/02/2025 12:33:11 PM - [HTTP] Basic Password : bambam
/var/log/responder/Responder-Session.log:11/02/2025 12:36:12 PM - [HTTP] Basic Password : estrella
2025-02-28 19:54:44 -03:00
8 changed files with 74 additions and 19 deletions

View File

@@ -15,6 +15,6 @@
if ! [ "$SEARCH_IN_FOLDER" ]; then
print_2title "Searching passwords inside logs (limit 70)"
(find /var/log/ /var/logs/ /private/var/log -type f -exec grep -R -i "pwd\|passw" "{}" \;) 2>/dev/null | sed '/^.\{150\}./d' | sort | uniq | grep -v "File does not exist:\|modules-config/config-set-passwords\|config-set-passwords already ran\|script not found or unable to stat:\|\"GET /.*\" 404" | head -n 70 | sed -${E} "s,pwd|passw,${SED_RED},"
(find /var/log/ /var/logs/ /private/var/log -type f -exec grep -R -H -i "pwd\|passw" "{}" \;) 2>/dev/null | sed '/^.\{150\}./d' | sort | uniq | grep -v "File does not exist:\|modules-config/config-set-passwords\|config-set-passwords already ran\|script not found or unable to stat:\|\"GET /.*\" 404" | head -n 70 | sed -${E} "s,pwd|passw,${SED_RED},"
echo ""
fi
fi

View File

@@ -37,9 +37,10 @@ Basic options:
---- --------------- -------- -----------
PARAMETERS no Parameters to pass to the script
PASSWORD um1xipfws17nkw1bi1ma3bh7tzt4mo3e no Password to encrypt and obfuscate the script (randomly generated). The length must be 32B. If no password is set, only base64 will be used
.
PEASS_URL https://raw.githubusercontent.com/peass-ng/PEASS-ng/master/winPEAS/wi yes Path to the PEASS script. Accepted: http(s):// URL or absolute local path. Linpeas: https://raw.githubusercontent.com/peass-ng/PEASS-ng
nPEASexe/binaries/Obfuscated%20Releases/winPEASany.exe /master/linPEAS/linpeas.sh
WINPEASS true yes Use PEASS for Windows or PEASS for linux. Default is windows change to false for linux.
CUSTOM_URL no Path to the PEASS script. Accepted: http(s):// URL or absolute local path.
SESSION yes The session to run this module on.
SRVHOST no Set your metasploit instance IP if you want to download the PEASS script from here via http(s) instead of uploading it.
SRVPORT 443 no Port to download the PEASS script from using http(s) (only used if SRVHOST)

View File

@@ -37,7 +37,8 @@ class MetasploitModule < Msf::Post
))
register_options(
[
OptString.new('PEASS_URL', [true, 'Path to the PEASS script. Accepted: http(s):// URL or absolute local path. Linpeas: https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh', "https://github.com/peass-ng/PEASS-ng/releases/latest/download/winPEASany_ofs.exe"]),
OptString.new('WINPEASS', [true, 'Which PEASS script to use. Use True for WinPeass and false for LinPEASS', true]),
OptString.new('CUSTOM_URL', [false, 'URL to download the PEASS script from (if not using the default one). Accepts http(s) or absolute path. Overrides the WINPEASS variable', '']),
OptString.new('PASSWORD', [false, 'Password to encrypt and obfuscate the script (randomly generated). The length must be 32B. If no password is set, only base64 will be used.', rand(36**32).to_s(36)]),
OptString.new('TEMP_DIR', [false, 'Path to upload the obfuscated PEASS script inside the compromised machine. By default "C:\Windows\System32\spool\drivers\color" is used in Windows and "/tmp" in Unix.', '']),
OptString.new('PARAMETERS', [false, 'Parameters to pass to the script', nil]),
@@ -237,8 +238,14 @@ class MetasploitModule < Msf::Post
def load_peass
# Load the PEASS script from a local file or from Internet
peass_script = ""
url_peass = datastore['PEASS_URL']
url_peass = ""
# If no URL is set, use the default one
if datastore['CUSTOM_URL'] != ""
url_peass = datastore['CUSTOM_URL']
else
url_peass = datastore['WINPEASS'] ? "https://github.com/peass-ng/PEASS-ng/releases/latest/download/winPEASany_ofs.exe" : "https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh"
end
# If URL is set, check if it is a valid URL or local file
if url_peass.include?("http://") || url_peass.include?("https://")
target = URI.parse url_peass
raise 'Invalid URL' unless target.scheme =~ /https?/

0
parsers/__init__.py Normal file
View File

View File

@@ -144,7 +144,12 @@ def parse_line(line: str):
})
def main():
def parse_peass(outputpath: str, jsonpath: str = ""):
global OUTPUT_PATH, JSON_PATH
OUTPUT_PATH = outputpath
JSON_PATH = jsonpath
for line in open(OUTPUT_PATH, 'r', encoding="utf8").readlines():
line = line.strip()
if not line or not clean_colors(line): #Remove empty lines or lines just with colors hex
@@ -152,17 +157,21 @@ def main():
parse_line(line)
with open(JSON_PATH, "w") as f:
json.dump(FINAL_JSON, f)
if JSON_PATH:
with open(JSON_PATH, "w") as f:
json.dump(FINAL_JSON, f)
else:
return FINAL_JSON
# Start execution
if __name__ == "__main__":
try:
OUTPUT_PATH = sys.argv[1]
JSON_PATH = sys.argv[2]
outputpath = sys.argv[1]
jsonpath = sys.argv[2]
parse_peass(outputpath, jsonpath)
except IndexError as err:
print("Error: Please pass the peas.out file and the path to save the json\npeas2json.py <output_file> <json_file.json>")
sys.exit(1)
main()

View File

@@ -594,7 +594,7 @@ namespace winPEAS.Checks
try
{
Beaprint.MainPrint("Checking KrbRelayUp");
Beaprint.LinkPrint("https://book.hacktricks.wiki/en/windows-hardening/windows-local-privilege-escalation/index.html#krbrelayupp");
Beaprint.LinkPrint("https://book.hacktricks.wiki/en/windows-hardening/windows-local-privilege-escalation/index.html#krbrelayup");
if (Checks.CurrentAdDomainName.Length > 0)
{

View File

@@ -184,9 +184,17 @@ namespace winPEAS.Helpers
//////////////////////
public static List<string> ListFolder(String path)
{
string root = @Path.GetPathRoot(Environment.SystemDirectory) + path;
var dirs = from dir in Directory.EnumerateDirectories(root) select dir;
return dirs.ToList();
try
{
string root = @Path.GetPathRoot(Environment.SystemDirectory) + path;
var dirs = from dir in Directory.EnumerateDirectories(root) select dir;
return dirs.ToList();
}
catch(Exception ex)
{
//Path can't be accessed
return new List<string>();
}
}
internal static byte[] CombineArrays(byte[] first, byte[] second)

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Diagnostics;
namespace winPEAS.Info.CloudInfo
{
@@ -28,7 +29,20 @@ namespace winPEAS.Info.CloudInfo
const string API_VERSION = "2021-12-13";
const string CONTAINER_API_VERSION = "2019-08-01";
// **New helper method to detect if running inside an Azure container**
public static bool DoesProcessExist(string processName)
{
// Return false if the process name is null or empty
if (string.IsNullOrEmpty(processName))
{
return false;
}
// Retrieve all processes matching the specified name
Process[] processes = Process.GetProcessesByName(processName);
return processes.Length > 0;
}
// New helper method to detect if running inside an Azure container
private bool IsContainer()
{
return !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("IDENTITY_ENDPOINT")) ||
@@ -123,6 +137,22 @@ namespace winPEAS.Info.CloudInfo
}
}
string hwsRun = DoesProcessExist("HybridWorkerService") ? "Yes" : "No";
_endpointDataList.Add(new EndpointData()
{
EndpointName = "HybridWorkerService.exe Running",
Data = hwsRun,
IsAttackVector = true
});
string OSRun = DoesProcessExist("Orchestrator.Sandbox") ? "Yes" : "No";
_endpointDataList.Add(new EndpointData()
{
EndpointName = "Orchestrator.Sandbox.exe Running",
Data = OSRun,
IsAttackVector = true
});
_endpointData.Add("General", _endpointDataList);
}
catch (Exception ex)