antmar904 Posted March 22, 2018 Share Posted March 22, 2018 Hello I need help from my RegEx wizards once. I've tried many many RegEx but I can't seem to get it. Here is the test string: Account Name: test Account Domain: test Logon ID: aasdfasdf New Account: Security ID: test\test Account Name: test Account Domain: test\test Attributes: SAM Account Name: test Display Name: test, tester tested User Principal Name: test@test.com Home Directory: - Home Drive: - Script Path: - Profile Path: - User Workstations: - Password Last Set: <never> Account Expires: <never> Primary Group ID: 513 Allowed To Delegate To: - Old UAC Value: 0x0 New UAC Value: 0x11 User Account Control: Account Disabled 'Normal Account' - Enabled User Parameters: - SID History: - Logon Hours: <value not set> Additional Information: Privileges - I am trying to get the string "test" after "Account Name:" and the string "test" after "SAM Account Name:". The string above is from a DC payload when a new AD user account gets created so the payload output should be the same. Thanks again all for your help! Link to comment Share on other sites More sharing options...
TheXman Posted March 22, 2018 Share Posted March 22, 2018 (edited) Just one of many different solutions #include <Constants.au3> #include <Array.au3> example() ;========================================================================== ; ;========================================================================== Func example() Const $kDATA = "Account Name: test Account Domain: test Logon ID: aasdfasdf New Account: Security ID: test\test Account Name: test Account Domain: test\test Attributes: SAM Account Name: test Display Name: test, tester tested User Principal Name: test@test.com Home Directory: - Home Drive: - Script Path: - Profile Path: - User Workstations: - Password Last Set: <never> Account Expires: <never> Primary Group ID: 513 Allowed To Delegate To: - Old UAC Value: 0x0 New UAC Value: 0x11 User Account Control: Account Disabled 'Normal Account' - Enabled User Parameters: - SID History: - Logon Hours: <value not set> Additional Information: Privileges" Local $aResult = StringRegExp($kDATA, "Account Name: ([^ ]*).*?SAM Account Name: ([^ ]*)", $STR_REGEXPARRAYMATCH) If IsArray($aResult) Then _ArrayDisplay($aResult) EndFunc Edited March 22, 2018 by TheXman antmar904 1 CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
antmar904 Posted March 26, 2018 Author Share Posted March 26, 2018 On 3/22/2018 at 11:21 AM, TheXman said: Just one of many different solutions #include <Constants.au3> #include <Array.au3> example() ;========================================================================== ; ;========================================================================== Func example() Const $kDATA = "Account Name: test Account Domain: test Logon ID: aasdfasdf New Account: Security ID: test\test Account Name: test Account Domain: test\test Attributes: SAM Account Name: test Display Name: test, tester tested User Principal Name: test@test.com Home Directory: - Home Drive: - Script Path: - Profile Path: - User Workstations: - Password Last Set: <never> Account Expires: <never> Primary Group ID: 513 Allowed To Delegate To: - Old UAC Value: 0x0 New UAC Value: 0x11 User Account Control: Account Disabled 'Normal Account' - Enabled User Parameters: - SID History: - Logon Hours: <value not set> Additional Information: Privileges" Local $aResult = StringRegExp($kDATA, "Account Name: ([^ ]*).*?SAM Account Name: ([^ ]*)", $STR_REGEXPARRAYMATCH) If IsArray($aResult) Then _ArrayDisplay($aResult) EndFunc thank you @TheXman that worked! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now