Skip to content

Commit 5bcdb1d

Browse files
zweilosecgitbook-bot
authored andcommitted
GitBook: [#312] No subject
1 parent 01ea203 commit 5bcdb1d

File tree

2 files changed

+54
-175
lines changed

2 files changed

+54
-175
lines changed

linux-1/linux-redteam/enumeration.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,34 @@ file $file
9696
lsof +L1
9797
```
9898

99+
### Read extended attributes of a file
100+
101+
```
102+
lsattr $file
103+
```
104+
105+
Normally, using this command on a directory will cause it to list the attributes of the files inside that directory. However, you can force `lsattr` to treat a directory as a file and produce file attribute information for it by using the `-d` command line option.
106+
107+
```
108+
lsattr -d /home/user
109+
```
110+
111+
### Change attributes of a file
112+
113+
```
114+
chattr $file
115+
```
116+
117+
> The format of a symbolic mode is `+-=[aAcCdDeijsStTu]`
118+
>
119+
> The operator `'+'` causes the selected attributes to be added to the existing attributes of the files; `'-'` causes them to be removed; and `'='` causes them to be the only attributes that the files have.
120+
>
121+
> The letters `'aAcCdDeijsStTu'` select the new attributes for the files: append only (a), no atime updates (A), compressed (c), no copy-on-write (C), no dump (d), synchronous directory updates (D), extent format (e), immutable (i), data journalling (j), secure deletion (s), synchronous updates (S), no tail-merging (t), top of directory hierarchy (T), and undeletable (u).
122+
>
123+
> The following attributes are read-only and may be listed by `lsattr` but not modified by `chattr`: compression error (E), huge file (h), indexed directory (I), inline data (N), compression raw access (X), and compressed dirty file (Z).
124+
>
125+
> Not all flags are supported or utilized by all filesystems; refer to filesystem-specific man pages such as btrfs, ext4, and xfs for more filesystem-specific details.
126+
99127
## Process Enumeration
100128

101129
## ps
@@ -724,4 +752,8 @@ find / -name ftp
724752
* [https://securityreason.com](https://securityreason.com)
725753
* [https://seclists.org/fulldisclosure/](https://seclists.org/fulldisclosure/)
726754

755+
## References
756+
757+
* [https://howtoforge.com/linux-lsattr-command/](https://howtoforge.com/linux-lsattr-command/)
758+
727759
If you like this content and would like to see more, please consider [buying me a coffee](https://www.buymeacoffee.com/zweilosec)!

windows-1/windows-redteam/enumeration.md

Lines changed: 22 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Most commands that run in cmd.exe will also run in PowerShell! This gives many m
1616

1717
## User Enumeration
1818

19-
### Get user information
19+
### Get user information:
2020

2121
{% tabs %}
2222
{% tab title="PowerShell" %}
@@ -85,76 +85,30 @@ There is a property called Password, though this did not return anything on my M
8585

8686
{% tabs %}
8787
{% tab title="PowerShell" %}
88-
Get list of local users
89-
90-
```powershell
91-
Get-LocalUser | Format-Table Name,Enabled,LastLogon,SID
92-
```
93-
94-
Inferring from user's home folders
95-
96-
```powershell
97-
Get-ChildItem C:\Users -Force | select Name
98-
```
99-
100-
Using WMI
101-
10288
```powershell
10389
Get-CimInstance -class Win32_UserAccount
10490
```
10591

10692
Gets display name, description, lockout status, password requirements, login name and domain, and SID.
10793

10894
If run on a domain connected machine dumps all accounts on the whole domain! On a non-domain joined machine lists all local users. Includes Service Accounts.  
109-
110-
### Groups
111-
112-
Get list of local groups
113-
114-
```powershell
115-
Get-LocalGroup | Format-Table Name,SID,Description
116-
```
117-
118-
List group members
119-
120-
```powershell
121-
Get-LocalGroupMember Administrators | Format-Table Name,PrincipalSource,SID
122-
```
123-
124-
PrincipleSource will tell you whether the account is a local, domain, or Microsoft account.
12595
{% endtab %}
12696

12797
{% tab title="cmd.exe" %}
12898
### Local machine Users & Groups Enumeration
12999

130-
Show current username
131-
132100
```
101+
#Show current user name
133102
net user %username%
134-
```
135-
136-
Show all local users
137103
138-
```
104+
#show all local users
139105
net users
140-
```
141-
142-
Show all local groups
143-
144-
```
145-
net localgroup
146-
```
147-
148-
Show who is inside Administrators group
149106
150-
```
151-
net localgroup Administrators
152-
```
107+
#Show all local groups
108+
net localgroup
153109
154-
Show who is currently logged in
155-
156-
```
157-
qwinsta
110+
#Show who is inside Administrators group
111+
net localgroup Administrators
158112
```
159113

160114
### Active Directory Users & Groups Enumeration
@@ -166,22 +120,6 @@ net group /domain
166120
{% endtab %}
167121
{% endtabs %}
168122

169-
#### Check for AutoLogon accounts
170-
171-
{% tabs %}
172-
{% tab title="PowerShell" %}
173-
```powershell
174-
Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon' | select "Default*"
175-
```
176-
{% endtab %}
177-
178-
{% tab title="cmd.exe" %}
179-
```
180-
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon" 2>null | findstr "DefaultUserName DefaultDomainName DefaultPassword"
181-
```
182-
{% endtab %}
183-
{% endtabs %}
184-
185123
### Active Directory
186124

187125
{% tabs %}
@@ -274,83 +212,17 @@ Many administrators set their account passwords to never expire, so searching fo
274212
Search-ADAccount -PasswordNeverExpires
275213
```
276214

277-
### Search for passwords
278-
279-
#### Search for keyword in registry
280-
281-
```
282-
reg query HKLM /f password /t REG_SZ /s
283-
reg query HKCU /f password /t REG_SZ /s
284-
```
285-
286-
The `/f` flag specifies the keyword to search for. In this case the word "password".
287-
288-
#### Search in Credential Manager
215+
### Find AutoLogon passwords
289216

290-
{% tabs %}
291-
{% tab title="PowerShell" %}
292-
```powershell
293-
Get-ChildItem -Hidden C:\Users\username\AppData\Local\Microsoft\Credentials\
294-
Get-ChildItem -Hidden C:\Users\username\AppData\Roaming\Microsoft\Credentials\
295217
```
296-
{% endtab %}
297-
298-
{% tab title="cmd.exe" %}
299-
```
300-
cmdkey /list
301-
dir C:\Users\username\AppData\Local\Microsoft\Credentials\
302-
dir C:\Users\username\AppData\Roaming\Microsoft\Credentials\
303-
```
304-
{% endtab %}
305-
{% endtabs %}
306-
307-
#### Check SAM and SYSTEM registry hives
308-
309-
If you can access these files and copy them, you can dump credentials for the system.
310-
311-
```
312-
%SYSTEMROOT%\repair\SAM
313-
%SYSTEMROOT%\System32\config\RegBack\SAM
314-
%SYSTEMROOT%\System32\config\SAM
315-
%SYSTEMROOT%\repair\system
316-
%SYSTEMROOT%\System32\config\SYSTEM
317-
%SYSTEMROOT%\System32\config\RegBack\system
318-
```
319-
320-
### File Permissions
321-
322-
Find files/folders where the "Everyone" group has permissions.  
323-
324-
{% tabs %}
325-
{% tab title="PowerShell" %}
326-
```powershell
327-
Get-ChildItem 'C:\Program Files\','C:\Program Files (x86)\' -Recurse | % { try { Get-Acl $_ -EA SilentlyContinue | Where {($_.Access|select -ExpandProperty IdentityReference) -match 'Everyone'} } catch {}}
328-
329-
Get-ChildItem 'C:\Program Files\','C:\Program Files (x86)\' -Recurse | % { try { Get-Acl $_ -EA SilentlyContinue | Where {($_.Access|select -ExpandProperty IdentityReference) -match 'BUILTIN\Users'} } catch {}}
218+
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon" 2>null | findstr "DefaultUserName DefaultDomainName DefaultPassword"
330219
```
331220

332-
This will recursively search the "Program Files" folders, ignoring (most) errors. 
333-
{% endtab %}
221+
### Search for "password" in registry
334222

335-
{% tab title="cmd.exe" %}
336223
```
337-
icacls "C:\Program Files\" /T /C 2>nul | findstr "Everyone"
338-
```
339-
340-
This will recursively (`/T`) search the "C:\Program Files\\" folder, ignoring errors (`/C`).
341-
{% endtab %}
342-
{% endtabs %}
343-
344-
 More good groups to search for would be the "BUILTIN\Users" or "Domain Users" groups.
345-
346-
#### Using accesschk.exe (SysInternals)
347-
348-
You can also use `accesschk.exe` from Sysinternals to check for writeable folders and files.
349-
350-
```
351-
accesschk.exe -qwsu "Everyone" *
352-
accesschk.exe -qwsu "Authenticated Users" *
353-
accesschk.exe -qwsu "Users" *
224+
reg query HKLM /f password /t REG_SZ /s
225+
reg query HKCU /f password /t REG_SZ /s
354226
```
355227

356228
## OS Information
@@ -734,24 +606,6 @@ If you are having this error (for example with SSDPSRV):
734606
>
735607
> Note: In Windows XP SP1, the service upnphost depends on SSDPSRV to work
736608
737-
### Unquoted service paths
738-
739-
Unquoted service paths are paths to services that contain a space in them, that are not surrounded by quotes. These paths can be hijacked to run arbitrary code if the break in the path is a writeable location.
740-
741-
{% tabs %}
742-
{% tab title="PowerShell" %}
743-
```powershell
744-
Get-CimInstance -class Win32_Service -Property Name, DisplayName, PathName, StartMode | Where {$_.StartMode -eq "Auto" -and $_.PathName -notlike "C:\Windows*" -and $_.PathName -notlike '"*'} | select PathName,DisplayName,Name
745-
```
746-
{% endtab %}
747-
748-
{% tab title="cmd.exe" %}
749-
```
750-
wmic service get name,displayname,pathname,startmode 2>nul |findstr /i "Auto" 2>nul |findstr /i /v "C:\Windows\\" 2>nul |findstr /i /v """
751-
```
752-
{% endtab %}
753-
{% endtabs %}
754-
755609
### Get running processes
756610
757611
{% tabs %}
@@ -944,27 +798,30 @@ ForEach ($Connection in $CONNECTIONS)
944798

945799
[https://github.com/carlospolop/hacktricks/blob/master/windows/basic-cmd-for-pentesters.md#network](https://github.com/carlospolop/hacktricks/blob/master/windows/basic-cmd-for-pentesters.md#network) (TODO:check for more network enumeration info here)
946800

947-
### Startup/AutoRuns
801+
### AutoRuns
948802

949-
Check which files are executed when the computer is started, or a user is logged in. 
803+
Check which files are executed when the computer is started. Components that are executed when a user logins can be exploited to execute malicious code when the administrator logins. (cmd.exe)
950804

951805
{% tabs %}
952806
{% tab title="PowerShell" %}
807+
808+
953809
```powershell
954810
Get-CimInstance Win32_StartupCommand | select Name, command, Location, User | fl
955811
Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run'
956812
Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce'
957813
Get-ItemProperty -Path 'Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run'
958814
Get-ItemProperty -Path 'Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce'
959-
Get-ChildItem "C:\Users\All Users\Start Menu\Programs\Startup" -Force
960-
Get-ChildItem "C:\Users\$env:USERNAME\Start Menu\Programs\Startup" -Force
961-
Get-ChildItem "C:\Users\$env:USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup" -Force
815+
Get-ChildItem "C:\Users\All Users\Start Menu\Programs\Startup"
816+
Get-ChildItem "C:\Users\$env:USERNAME\Start Menu\Programs\Startup"
962817
```
963818
{% endtab %}
964819

965820
{% tab title="cmd.exe" %}
821+
822+
966823
```
967-
wmic startup get caption,command 2>nul
824+
wmic startup get caption,command 2>nul & ^
968825
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Run 2>nul & ^
969826
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce 2>nul & ^
970827
reg query HKCU\Software\Microsoft\Windows\CurrentVersion\Run 2>nul & ^
@@ -1014,24 +871,14 @@ Server Message Block is a service that enables the user to share files with othe
1014871
* `smbver.sh $ip $port` 
1015872
* Use Wireshark to check pcap
1016873

1017-
### List share drives
874+
### Share List:
1018875

1019876
```bash
1020877
smbclient --list $ip
1021878
smbclient -L $ip
1022879
smbmap -H $computer
1023880
```
1024881

1025-
#### Find all connected drives
1026-
1027-
This can show all connected hard drives, not only network fileshares
1028-
1029-
```powershell
1030-
Get-PSDrive | where {$_.Provider -like "Microsoft.PowerShell.Core\FileSystem"}| ft Name,Root
1031-
```
1032-
1033-
Listing all PSDrives can also give you valuable information, showing how to access environment variables, certificates, registry keys, temp folders, and more.
1034-
1035882
### Check for SMB vulnerabilities:
1036883

1037884
```bash

0 commit comments

Comments
 (0)