forked from dfirdeferred/Trimarcisia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trimarcisia.ps1
82 lines (70 loc) · 2.63 KB
/
Trimarcisia.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<#
.SYNOPSIS
This tool makes it easy to download and open Trimarc Security tools available to help
the enterprise secure Active Directory.
.DESCRIPTION
Trimarcisia, which translates to "feat of three horsemen", was a military cavalry tactic
used by the ancient Celts. If one horse or soldier fell, another was there to take their
place and continue the fight.
.INPUTS
None
.OUTPUTS
New folder(s) containing repositories from the Trimarc GitHub.
.LINK
https://github.com/dfirdeferred/Trimarcisia
.NOTES
Author: Darryl G. Baker
#>
# Print ASCII Art
Write-Output " _____ _ _ "
Write-Output "|___ / | | | | ___ _ __ ___ ___ _ __ ___ ___ _ __ "
Write-Output " |_ \ | |_| |/ _ \| '__/ __|/ _ \ '_ \` _ \ / _ \ '_ \ "
Write-Output " ___) | | _ | (_) | | \__ \ __/ | | | | | __/ | | |"
Write-Output "|____/ |_| |_|\___/|_| |___/\___|_| |_| |_|\___|_| |_|"
# List of repositories
$api = "https://api.github.com/repos/trimarc"
$repos = (Invoke-RestMethod -Method GET -Uri https://api.github.com/users/Trimarc/repos).Name
# Function to download and unzip the repository
function Download-Repo {
param (
[string]$repoName
)
if (-not (Test-Path -Path $repoName)) {
Write-Output "Downloading $repoName..."
$repo = Invoke-RestMethod -Uri "$api/$repoName" -Method GET
$currentBranch = $repo.default_branch
$zipUrl = $repo.archive_url -replace "{archive_format}{/ref}", "zipball/$currentBranch"
Invoke-RestMethod -Uri $zipUrl -OutFile "$repoName.zip"
Write-Output "Unzipping $repoName..."
Expand-Archive -Path "$repoName.zip" -DestinationPath $repoName
Remove-Item "$repoName.zip"
Start-Process -FilePath $repoName
}
else {
Write-Output "$repoName already downloaded."
Start-Process -FilePath $repoName
}
}
# Display list of repositories
Write-Output "Please select a repository to download/open:"
Write-Output "0. Download all repositories"
for ($i = 0; $i -lt $repos.Count; $i++) {
Write-Output "$(($i + 1)). $($repos[$i])"
}
# Read user input
$selection = [int](Read-Host "Enter the number of the repository you want to download/open")
# Validate user input
if ($selection -eq 0) {
foreach ($repoName in $repos) {
Download-Repo -repoName $repoName
}
Write-Output "All repositories have been downloaded."
}
elseif ($selection -ge 1 -and $selection -le $repos.Count) {
$repoName = $repos[$selection - 1]
Download-Repo -repoName $repoName
}
else {
Write-Output "Invalid selection. Exiting."
exit 1
}