potatoqualitee / disarepotools

πŸ¦… DISA Patch Repository Tools - List, download files and install files from DISA patch repositories using your smartcard
MIT License
5 stars 1 forks source link

Repo availability #8

Open Architeqt opened 2 years ago

Architeqt commented 2 years ago

Potato,

So I've been tweaking your scripts/learning quite a bit about Powershell (I'm only decent at Bash scripting and fairly good at Regex) through modifying them and found out after that you had posted this:

.PARAMETER Repository The repository to connect to. Currently, only the following repos are supported:

    MicrosoftSecurityBulletins
    MicrosoftSecurityAdvisories
    MicrosoftApplications
    MicrosoftToolkits

    Defaults to MicrosoftSecurityBulletins

Now, I assumed you meant One of Two things, and unfortunately have come to the understanding you meant the former - is this correct?

  1. Only the listed repos above are supported via powershell call as standard/non admin users
  2. The other repos haven't been carved out within your script

Since I need access to the ACAS and ESS plugins/zips, am I out of luck? How did you find out what repos were available?

Thanks!

potatoqualitee commented 2 years ago

Hey Architeqt!

fairly good at Regex

Nice πŸ‘‘ I am horrible at it as you can see in some of the comments in my code lol

Number two is correct. I just haven't parsed out the others and fit it neatly into my script bc it wasn't within scope.

This script was built on a script that downloads the ACAS files, so you're very much in luck. I can't seem to find it right now, tho.

To get the ID, I either looked at the querystring at the top or used the Developer Tools to see what was going on. I use the Chrome Developer Tools extensively and just mimic that behavior.

Architeqt commented 2 years ago

That was the only reason I brought up Regex - if you need anything matched I can help you out. This script will save my colleagues quite a ton of time and I'm all about automation/making other lives easier.

Wait so you initially found a script that's specific to the ACAS files? definitely going to poke around for that then, need to increase my github search skills clearly..

Yeah so I was able to get the ID just fine, but the named portion of the repository kept throwing errors when I tried anything outside of the Microsoft Repos you listed in your connect.ps

Thanks for all your help!

potatoqualitee commented 2 years ago

That was the only reason I brought up Regex - if you need anything matched I can help you out.

Oh good! haha yes, I need help with this please

https://github.com/potatoqualitee/disarepotools/blob/main/public/Get-DisaFile.ps1#L369

This script will save my colleagues quite a ton of time and I'm all about automation/making other lives easier.

Sweet! I also have https://github.com/potatoqualitee/tentools that may save them time for acas deployments as well.

Wait so you initially found a script that's specific to the ACAS files

Yes, but my colleague @luzkenin wrote it and it's not on GitHub, give me a moment and I'll look harder 😊

Yeah so I was able to get the ID just fine, but the named portion of the repository kept throwing errors when I tried anything outside of the Microsoft Repos you listed in your connect.ps

The limitation is just in the code. You'd have to update here:

https://github.com/potatoqualitee/disarepotools/blob/main/disarepotools.psm1#L49

Then restart PowerShell or just set $global:disarepotools = $null (if that doesn't work, Remove-Variable should) to reset the global variables. I used a global var instead of a script var bc I wanted to keep that cache as long as possible, even after I reloaded my PowerShell module changes.

potatoqualitee commented 2 years ago

Here you go! I learned so much from these scripts like that HEAD technique and that you can actually login to places using a smartcard 😊

Save-ACASFeedFiles.txt Get-ACASFiles.txt

As for the name of the repository, I just made it easy to read for humans, and easily tabbable/autocompletable.

potatoqualitee commented 2 years ago

I also like that he checks for the SHA matches and wanted to keep that functionality, which is another reason that I didn't add it to the module just yet. I'd have to figure out how and where it fits.

Architeqt commented 2 years ago

Holy moly, going to take me some time to parse through this

Seriously huge thanks to you and Luz - Wish I could reply directly to comments but I've only created this account to work directly with you, have never communicated on here before so please forgive current ignorance/brevity.

I'm getting some current errors so I'll troubleshoot and reply again later, didn't want you to think I "Dined and Dashed" lmao

Thanks again!

Architeqt commented 2 years ago

Just to update with where I'm currently stuck (I've literally only scripted in BASH so this is entirely new to me, I have to peel this onion layer by layer - not directly asking for help, I'll figure it out at some point):

When trying to import-module disarepotools I'm getting the following error at the corresponding line

if ($doDotSource) { . $Path }
else { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scriptblock]::Create([io.file]::ReadAllText($Path))), $null, $null) }

Exception calling "InvokeScript" with "4" argument(s): "Cannot evaluate parameter 'Name' because its argument is specified as a script block and there is no input. A script block cannot be evaluated without input." At C:\Users\Architeqt\Documents\WindowsPowerShell\Modules\disarepotools\0.0.3\disarepotools.psm1:30 char:12 else { $ExecutionContext.InvokeCommand.InvokeScript($false, ([scr ...


    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ParameterBindingException
potatoqualitee commented 2 years ago

Happy to help ☺️ That generally means you have a syntax error. I import that weird long way because it's far faster for larger modules.

Try $doDotSource = $true on the commandline before reimporting and it'll probably be more helpful.

Architeqt commented 2 years ago

Hey Potato wanted to provide a quick update: Before the holidays kicked off I was able to sort everything except Save-DisaFile, it keeps throwing an error that it could not find the command within the module, but the module could not be loaded even though it sees it just fine. Outside of that, I've gotten pretty much everything else working as far as connecting, seeing the correct repo's etc.:

Save-DisaFile : The 'Save-DisaFile' command was found in the module 'disarepotools', but the module could not be loaded. For more information, run 'Import-Module disarepotools'. At line:1 char:1

Architeqt commented 2 years ago

Turns out, "-executionpolicy bypass" only gets you so far in a Restricted session.. After setting the current environment to Unrestricted I was able to download some files (success!)..however.. I'm not getting all the files listed in Get-DisaFile and it seems to only be downloading 2 or 4 of the 10+ files listed.

Thankfully troubleshooting is in our DNA so it's back to the grind for me - we'll get there someday. Thanks for all your help and content!

potatoqualitee commented 2 years ago

Interesting! πŸ€” Please let me know what you find. I'm currently working on this module, but on the install/uninstall commands which are not yet exported.

What kind of restricted setting do you use? Constrained Language Mode?

Architeqt commented 2 years ago

Will do - honestly I don't know which restricted setting was configured by our Systems team. I'm just trying to work around it, see if I can make ends meet without bugging them about it. If it helps I ran "Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process". I don't even know where to see Constrained Language Mode restriction as it isn't listed under Get-ExecutionPolicy -List.