From 47ed72a5aa6701e7026eaf6e360753925ed19960 Mon Sep 17 00:00:00 2001 From: Mo Figueroa Date: Sun, 8 Sep 2024 12:06:32 -0400 Subject: [PATCH] Updating scripts Signed-off-by: Mo Figueroa --- DockerIMGBad/Dockerfile | 2 - DockerIMGElasticsearch/dockerfile | 36 -------------- .../{NMAUserG.ps1 => AddUserstoAnyGroup.ps1} | 17 ++++--- powershell/ChangePassword.ps1 | 1 - python/cmcbotelastic.py | 47 ------------------- python/youbad.py | 24 ---------- 6 files changed, 8 insertions(+), 119 deletions(-) delete mode 100644 DockerIMGBad/Dockerfile delete mode 100644 DockerIMGElasticsearch/dockerfile rename powershell/{NMAUserG.ps1 => AddUserstoAnyGroup.ps1} (82%) delete mode 100644 powershell/ChangePassword.ps1 delete mode 100644 python/cmcbotelastic.py delete mode 100644 python/youbad.py diff --git a/DockerIMGBad/Dockerfile b/DockerIMGBad/Dockerfile deleted file mode 100644 index ed3738e..0000000 --- a/DockerIMGBad/Dockerfile +++ /dev/null @@ -1,2 +0,0 @@ -FROM alpine:3.14.0 -RUN echo "testuser:x:10999:10999:,,,:/home/testuser:/bin/bash" >> /etc/passwd && echo "testuser::18761:0:99999:7:::" >> /etc/shadow \ No newline at end of file diff --git a/DockerIMGElasticsearch/dockerfile b/DockerIMGElasticsearch/dockerfile deleted file mode 100644 index 0d5c3b7..0000000 --- a/DockerIMGElasticsearch/dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -# -# Elasticsearch Dockerfile -# -# https://github.com/dockerfile/elasticsearch -# - -# Pull base image. -FROM dockerfile/java:oracle-java8 - -ENV ES_PKG_NAME elasticsearch-1.5.0 - -# Install Elasticsearch. -RUN \ - cd / && \ - wget https://download.elasticsearch.org/elasticsearch/elasticsearch/$ES_PKG_NAME.tar.gz && \ - tar xvzf $ES_PKG_NAME.tar.gz && \ - rm -f $ES_PKG_NAME.tar.gz && \ - mv /$ES_PKG_NAME /elasticsearch - -# Define mountable directories. -VOLUME ["/data"] - -# Mount elasticsearch.yml config -ADD config/elasticsearch.yml /elasticsearch/config/elasticsearch.yml - -# Define working directory. -WORKDIR /data - -# Define default command. -CMD ["/elasticsearch/bin/elasticsearch"] - -# Expose ports. -# - 9200: HTTP -# - 9300: transport -EXPOSE 9200 -EXPOSE 9300 \ No newline at end of file diff --git a/powershell/NMAUserG.ps1 b/powershell/AddUserstoAnyGroup.ps1 similarity index 82% rename from powershell/NMAUserG.ps1 rename to powershell/AddUserstoAnyGroup.ps1 index 46d0cbe..bab4a91 100644 --- a/powershell/NMAUserG.ps1 +++ b/powershell/AddUserstoAnyGroup.ps1 @@ -3,7 +3,7 @@ - The following function will take a csv formatted with columns named: Project Assignment,Status,Staff person,Work Email Address - The function will use the Work Email Address column to go through each entry - If a blank entry is found it will be skipped. - - If the column contains an email NOT like @nanmckay.com it will be skipped. + - If the column contains an email NOT like @domain.com it will be skipped. .Prerequisites You must run this script on a PowerShell Version 5.1 or higher and have the latest MSOLService module installed. --> Install-Module -Name MSOnline -Force @@ -13,12 +13,11 @@ 1. Load the function into powershell with: . .\Add-NMAUsrToGroup.ps1 2. Add users' email in the full_list_upn.csv into a security group named Something use the following syntax: --> Add-NMAUserToGroup -SourceCSVPath full_list_upn.csv -GroupName Something -.NOTES - Filename: Add-NMAUsrToGroup.ps1 - Author: GemTeam - Version 1 -#> -function Add-NMAUserToGroup { + 3. Add users' email in the full_list_upn.csv into a security group named Something use the following syntax: + --> Add-NMAUserToGroup -SourceCSVPath full_list_upn.csv -GroupName Something -GroupType AD + + +function Add-UserToGroup { [CmdletBinding()] param ( [Parameter(Mandatory=$true)][String]$SourceCSVPath, @@ -38,14 +37,14 @@ function Add-NMAUserToGroup { Write-Host "Skipping blank" continue } - if ($name."Work Email Address" -like "*@nanmckay.com") { + if ($name."Work Email Address" -like "*@domain.com") { $gmsg = "Adding " + $name."Work Email Address" + " to " + $GroupName Write-Host $gmsg -BackgroundColor Black -ForegroundColor Green Add-ADGroupMember -Identity $GroupName -members $name."Work Email Address" } else { $name."Work Email Address" - Write-Host "Cannot process entry since it is not a blank or email doesn't end with @nanmckay.com" + Write-Host "Cannot process entry since it is not a blank or email doesn't end with @domain.com" } } diff --git a/powershell/ChangePassword.ps1 b/powershell/ChangePassword.ps1 deleted file mode 100644 index de79714..0000000 --- a/powershell/ChangePassword.ps1 +++ /dev/null @@ -1 +0,0 @@ -Set-ADAccountPassword "CN=icontrolddc,OU=Internal,OU=Prosearchers,DC=prosearch,DC=us" -Reset -NewPassword (ConvertTo-SecureString -AsPlainText "password" -Force) \ No newline at end of file diff --git a/python/cmcbotelastic.py b/python/cmcbotelastic.py deleted file mode 100644 index 641cb04..0000000 --- a/python/cmcbotelastic.py +++ /dev/null @@ -1,47 +0,0 @@ -import datetime -from polygon import RESTClient -import ta -import config -import pandas as pd -import json -import ndjson -from ta.volatility import BollingerBands, AverageTrueRange -from ta.trend import IchimokuIndicator -from elasticsearch import Elasticsearch - - -def ts_to_datetime(ts) -> str: - return datetime.datetime.fromtimestamp(ts / 1000.0).strftime('%Y-%m-%d %H:%M') - - -def main(): - key = "ASgqNjwGk9Odpeje4ry_x_3pMSNMDyAo" - es = Elasticsearch([{'host': 'localhost', 'port': 9200}], http_auth=('elastic', 'changeme')) - # RESTClient can be used as a context manager to facilitate closing the underlying http session - # https://requests.readthedocs.io/en/master/user/advanced/#session-objects - with RESTClient(key) as client: - from_ = "2021-06-01" - to = "2021-06-18" - resp = client.stocks_equities_aggregates("SPY", 60, "minute", from_, to, unadjusted=False) - - print(type(resp.results)) - - jsString = json.dumps(resp.results) - #print(type(jsString)) - #print(jsString) - - #print(f"Minute aggregates for {resp.ticker} between {from_} and {to}.") - - #for result in resp.results: - # dt = ts_to_datetime(result["t"]) - # print(f"{dt}\n\tO: {result['o']}\n\tH: {result['h']}\n\tL: {result['l']}\n\tC: {result['c']} ") - for timeint in resp.results: - #dt = ts_to_datetime(result["t"]) - timeint['sym'] = 'SPY' - timeint['t'] = ts_to_datetime(timeint["t"]) - js = json.dumps(timeint) - print(js) - res = es.index(index='stock',doc_type='spy',body=js) - -if __name__ == '__main__': - main() diff --git a/python/youbad.py b/python/youbad.py deleted file mode 100644 index dd31db7..0000000 --- a/python/youbad.py +++ /dev/null @@ -1,24 +0,0 @@ -import hashlib -print("I am very insecure. Bandit thinks so too.") -#B110 -xs=[1,2,3,4,5,6,7,8] -try: - print(xs[7]) - print(xs[8]) -except: pass - -ys=[1, 2, None, None] -for y in ys: - try: - print(str(y+3)) #TypeErrors ahead - except: continue #not how to handle them - -#some imports -import telnetlib -import ftplib - -#B303 and B324 -s = b"I am a string" -print("MD5: " +hashlib.md5(s).hexdigest()) -print("SHA1: " +hashlib.sha1(s).hexdigest()) -print("SHA256: " +hashlib.sha256(s).hexdigest()) \ No newline at end of file