Skip to content

Commit eeb5ba6

Browse files
committed
Added and updated various cmdlets:
Cmdlets added: - Get-ADComputer - Get-RemoteSmbShare - Stop-Process Cmdlets updated: - Get-SystemInfo: Stability improvements - Get-ChildItem: Added support for listing env: and some refactoring - Get-ItemProperty: Implemented -Name option - Get-Process: Implemented -Name option - Resolve-DnsName: Implemented -Type option Some minor improvements Updated README Updated Twitter handle in all files
1 parent 1d608c6 commit eeb5ba6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1658
-129
lines changed

NoPowerShell.cna

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# | |\ | (_) | __/ (_) \ V V / __/ | ___) | | | | __/ | |
55
# |_| \_|\___/|_| \___/ \_/\_/ \___|_| |____/|_| |_|\___|_|_|
66
#
7-
# @_bitsadmin
7+
# @bitsadmin
88
# https://github.com/bitsadmin
99
#
1010

README.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ NoPowerShell is a tool implemented in C# which supports executing PowerShell-lik
33

44
Moreover, this project makes it easy for everyone to extend its functionality using only a few lines of C# code.
55

6+
Latest binary available from the [Releases](https://github.com/bitsadmin/nopowershell/releases) page.
7+
68
# Screenshots
79
## Running in Cobalt Strike
810
![NoPowerShell supported commands](https://raw.githubusercontent.com/bitsadmin/nopowershell/master/Pictures/CurrentlySupportedCommands.png "NoPowerShell in Cobalt Strike")
@@ -22,6 +24,7 @@ When using NoPowerShell from cmd.exe or PowerShell, you need to escape the pipe
2224
| List all commands supported by NoPowerShell | `Get-Command` | |
2325
| Get help for a command | `Get-Help -Name Get-Process` | Alternative: `man ps` |
2426
| Show current user | `NoPowerShell.exe whoami` | Unofficial command |
27+
| List SMB shares of MyServer | `Get-RemoteSmbShare \\MyServer` | Unofficial command |
2528
| List all user groups in domain | `Get-ADGroup -Filter *` | |
2629
| List all administrative groups in domain | `Get-ADGroup -LDAPFilter "(admincount=1)" \| select Name` | |
2730
| List all properties of the Administrator domain user | `Get-ADUser -Identity Administrator -Properties *` | |
@@ -36,6 +39,10 @@ When using NoPowerShell from cmd.exe or PowerShell, you need to escape the pipe
3639
| List all active members of the Administrators group | `Get-LocalGroupMember -Group Administrators \| ? Disabled -eq False` | |
3740
| List all local users | `Get-LocalUser` | |
3841
| List details of a specific user | `Get-LocalUser Administrator` | |
42+
| List all properties of the DC01 domain computer | `Get-ADComputer -Identity DC01 -Properties *` | |
43+
| List all Domain Controllers | `Get-ADComputer -LDAPFilter "(msDFSR-ComputerReferenceBL=*)"` | |
44+
| List all computers in domain | `Get-ADComputer -Filter *` | |
45+
| List specific attributes of user | `Get-ADComputer DC01 -Properties Name,operatingSystem` | |
3946
| Copy file from one location to another | `copy C:\Tmp\nc.exe C:\Windows\System32\nc.exe` | |
4047
| Copy folder | `copy C:\Tmp\MyFolder C:\Tmp\MyFolderBackup` | |
4148
| Locate KeePass files in the C:\Users\ directory | `ls -Recurse -Force C:\Users\ -Include *.kdbx` | |
@@ -44,6 +51,9 @@ When using NoPowerShell from cmd.exe or PowerShell, you need to escape the pipe
4451
| List autoruns in the registry | `Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Run \| ft` | |
4552
| List processes | `Get-Process` | |
4653
| List processes on remote host | `Get-Process -ComputerName dc01.corp.local -Username Administrator -Password P4ssw0rd!` | |
54+
| Gracefully stop processes | `Stop-Process -Id 4512,7241` | |
55+
| Kill process | `Stop-Process -Force -Id 4512` | |
56+
| Kill all cmd.exe processes | `Get-Process cmd | Stop-Process -Force` | |
4757
| Obtain data of Win32_Process class from a remote system and apply a filter on the output | `gwmi "Select ProcessId,Name,CommandLine From Win32_Process" -ComputerName dc01.corp.local \| ? Name -Like *PowerShell* \| select ProcessId,CommandLine` | Explicit credentials can be specified using the `-Username` and `-Password` parameters |
4858
| View details about a certain service | `Get-WmiObject -Class Win32_Service -Filter "Name = 'WinRM'"` | |
4959
| Launch process using WMI | `Invoke-WmiMethod -Class Win32_Process -Name Create "cmd /c calc.exe"` | This can also be done on a remote system |
@@ -101,7 +111,6 @@ Use the TemplateCommand.cs file in the Commands folder to construct new cmdlets.
101111
| Run with the -MyInteger parameter which changes the number of iterations from its default number of 5 iterations to whatever number is provided | `gtc -MyInteger 10` |
102112
| Run with the -MyString parameter which changes the text that is printed from its default value of 'Hello World' to whatever string is provided | `gtc -MyString "Bye PowerShell"` |
103113
| Combination of parameters | `gtc -MyInteger 10 -MyString "Bye PowerShell"` |
104-
| Combination of parameters - Alternative | `gtc -MyInteger 10 -MyString "Bye PowerShell"` |
105114
| Combination of parameters - Using fact that MyString is the only mandatory parameter for this command | `gtc -MyInteger 10 "Bye PowerShell"` |
106115
| Command in combination with a couple of data manipulators in the pipe | `gtc "Bye PowerShell" -MyInteger 30 \| ? Attribute2 -Like Line1* \| select Attribute2 \| fl` |
107116

@@ -122,24 +131,32 @@ Execute the following steps to implement your own cmdlet:
122131
3. Make sure all results are stored in the `_results` variable.
123132
8. Remove all of the template sample code and comments from the file to keep the source tidy.
124133

134+
# Requested NoPowerShell cmdlets
135+
| Cmdlet | Description |
136+
| - | - |
137+
| Get-ADTrusts | Unofficial command showing equivalent of `nltest /domain_trusts /all_trusts /v` |
138+
| Get-QWinsta | Unofficial command showing equivalent of `qwinsta` / `query session` |
139+
| Invoke-Command | Using PSRemoting execute a command on a remote machine (which in that case will of course be logged) |
140+
| Get-Service | Include option to also show service paths like in `sc qc` |
141+
| * | Sysinternals utilities like `pipelist` and `sdelete` |
142+
125143
# Contributed NoPowerShell cmdlets
126144
Authors of additional NoPowerShell cmdlets are added to the table below. Moreover, the table lists commands that are requested by the community to add. Together we can develop a powerful NoPowerShell toolkit!
127145

128146
| Cmdlet | Contributed by | GitHub | Twitter | Description |
129147
| - | - | - | - | - |
130-
| Get-ADTrusts | | | | Unofficial command showing equivalent of `nltest /domain_trusts /all_trusts /v` |
131-
| Get-QWinsta | | | | Unofficial command showing equivalent of `qwinsta` / `query session` |
132-
| Invoke-Command | | | | |
133-
| Stop-Process | | | | |
148+
| | | | | |
134149

135150
# Included NoPowerShell cmdlets
136151
| Cmdlet | Category | Notes |
137152
| - | - | - |
138153
| Get-ADGroup | ActiveDirectory | |
139154
| Get-ADGroupMember | ActiveDirectory | |
140155
| Get-ADUser | ActiveDirectory | |
156+
| Get-ADComputer | ActiveDirectory | |
141157
| Get-SystemInfo | Additional | Few fields still need to be added to mimick systeminfo.exe |
142158
| Get-Whoami | Additional | whoami.exe /ALL is not implemented yet |
159+
| Get-RemoteSmbShare | Additional | |
143160
| Get-Command | Core | |
144161
| Get-Help | Core | |
145162
| Where-Object | Core | |
@@ -151,7 +168,8 @@ Authors of additional NoPowerShell cmdlets are added to the table below. Moreove
151168
| Get-ChildItem | Management | |
152169
| Get-Content | Management | |
153170
| Get-ItemProperty | Management | |
154-
| Get-Process | Management | Quick & dirty implementation |
171+
| Get-Process | Management | |
172+
| Stop-Process | Management | |
155173
| Get-WmiObject | Management | |
156174
| Invoke-WmiMethod | Management | Quick & dirty implementation |
157175
| Remove-Item | Management | |
@@ -165,4 +183,4 @@ Authors of additional NoPowerShell cmdlets are added to the table below. Moreove
165183
| Measure-Object | Utility |
166184
| Select-Object | Utility |
167185

168-
**Authored by Arris Huijgen (@_bitsadmin - https://github.com/bitsadmin)**
186+
**Authored by Arris Huijgen ([@bitsadmin](https://twitter.com/bitsadmin/) - https://github.com/bitsadmin/)**

Source/NoPowerShell/Arguments/Argument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22

33
/*
4-
Author: @_bitsadmin
4+
Author: @bitsadmin
55
Website: https://github.com/bitsadmin
66
License: BSD 3-Clause
77
*/

Source/NoPowerShell/Arguments/ArgumentList.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33

44
/*
5-
Author: @_bitsadmin
5+
Author: @bitsadmin
66
Website: https://github.com/bitsadmin
77
License: BSD 3-Clause
88
*/

Source/NoPowerShell/Arguments/BoolArgument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Author: @_bitsadmin
2+
Author: @bitsadmin
33
Website: https://github.com/bitsadmin
44
License: BSD 3-Clause
55
*/

Source/NoPowerShell/Arguments/IntegerArgument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Author: @_bitsadmin
2+
Author: @bitsadmin
33
Website: https://github.com/bitsadmin
44
License: BSD 3-Clause
55
*/

Source/NoPowerShell/Arguments/StringArgument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Author: @_bitsadmin
2+
Author: @bitsadmin
33
Website: https://github.com/bitsadmin
44
License: BSD 3-Clause
55
*/
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
using NoPowerShell.Arguments;
2+
using NoPowerShell.HelperClasses;
3+
using System;
4+
using System.Collections.Generic;
5+
6+
/*
7+
Author: @bitsadmin
8+
Website: https://github.com/bitsadmin
9+
License: BSD 3-Clause
10+
*/
11+
12+
namespace NoPowerShell.Commands
13+
{
14+
public class GetADComputerCommand : PSCommand
15+
{
16+
public GetADComputerCommand(string[] userArguments) : base(userArguments, SupportedArguments)
17+
{
18+
}
19+
20+
public override CommandResult Execute(CommandResult pipeIn)
21+
{
22+
// Obtain cmdlet parameters
23+
string identity = _arguments.Get<StringArgument>("Identity").Value;
24+
string ldapFilter = _arguments.Get<StringArgument>("LDAPFilter").Value;
25+
string filter = _arguments.Get<StringArgument>("Filter").Value;
26+
string properties = _arguments.Get<StringArgument>("Properties").Value;
27+
28+
// Determine filters
29+
bool filledIdentity = !string.IsNullOrEmpty(identity);
30+
bool filledLdapFilter = !string.IsNullOrEmpty(ldapFilter);
31+
bool filledFilter = !string.IsNullOrEmpty(filter);
32+
33+
// Input checks
34+
if (filledIdentity && filledLdapFilter)
35+
throw new InvalidOperationException("Specify either Identity or LDAPFilter, not both");
36+
if (!filledIdentity && !filledLdapFilter && !filledFilter)
37+
throw new InvalidOperationException("Specify either Identity, Filter or LDAPFilter");
38+
39+
// Build filter
40+
string filterBase = "(&(objectCategory=computer){0})";
41+
string queryFilter = string.Empty;
42+
43+
// -Identity DC01
44+
if (filledIdentity)
45+
queryFilter = string.Format(filterBase, string.Format("(cn={0})", identity));
46+
47+
// -LDAPFilter "(msDFSR-ComputerReferenceBL=*)"
48+
else if (filledLdapFilter)
49+
{
50+
queryFilter = string.Format(filterBase, ldapFilter);
51+
}
52+
53+
// -Filter *
54+
else if (filledFilter)
55+
{
56+
// TODO: allow more types of filters
57+
if (filter != "*")
58+
throw new InvalidOperationException("Currently only * filter is supported");
59+
60+
queryFilter = string.Format(filterBase, string.Empty);
61+
}
62+
63+
// Query
64+
_results = LDAPHelper.QueryLDAP(queryFilter, new List<string>(properties.Split(',')));
65+
66+
return _results;
67+
}
68+
69+
public static new CaseInsensitiveList Aliases
70+
{
71+
get { return new CaseInsensitiveList() { "Get-ADComputer" }; }
72+
}
73+
74+
public static new ArgumentList SupportedArguments
75+
{
76+
get
77+
{
78+
return new ArgumentList()
79+
{
80+
new StringArgument("Identity"),
81+
new StringArgument("Filter", true),
82+
new StringArgument("LDAPFilter", true),
83+
new StringArgument("Properties", "DistinguishedName,DNSHostName,Name,ObjectClass,ObjectGUID,SamAccountName,ObjectSID,UserPrincipalName", true)
84+
};
85+
}
86+
}
87+
88+
public static new string Synopsis
89+
{
90+
get { return "Gets one or more Active Directory computers."; }
91+
}
92+
93+
public static new ExampleEntries Examples
94+
{
95+
get
96+
{
97+
return new ExampleEntries()
98+
{
99+
new ExampleEntry("List all properties of the DC01 domain computer", "Get-ADComputer -Identity DC01 -Properties *"),
100+
new ExampleEntry("List all Domain Controllers", "Get-ADComputer -LDAPFilter \"(msDFSR-ComputerReferenceBL=*)\""),
101+
new ExampleEntry("List all computers in domain", "Get-ADComputer -Filter *"),
102+
new ExampleEntry("List specific attributes of user", "Get-ADComputer DC01 -Properties Name,operatingSystem")
103+
};
104+
}
105+
}
106+
}
107+
}

Source/NoPowerShell/Commands/ActiveDirectory/GetADGroupCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections.Generic;
55

66
/*
7-
Author: @_bitsadmin
7+
Author: @bitsadmin
88
Website: https://github.com/bitsadmin
99
License: BSD 3-Clause
1010
*/

Source/NoPowerShell/Commands/ActiveDirectory/GetADGroupMemberCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Collections.Generic;
44

55
/*
6-
Author: @_bitsadmin
6+
Author: @bitsadmin
77
Website: https://github.com/bitsadmin
88
License: BSD 3-Clause
99
*/

Source/NoPowerShell/Commands/ActiveDirectory/GetADUserCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections.Generic;
55

66
/*
7-
Author: @_bitsadmin
7+
Author: @bitsadmin
88
Website: https://github.com/bitsadmin
99
License: BSD 3-Clause
1010
*/

0 commit comments

Comments
 (0)