Posts

Showing posts with the label Powershell

[Solved] Fix upgrade errors in Kali Linux

Image
If you face errors from powershell-empire while upgrading Kali Linux, upgrade the pip packages for Flask and aiohttp with root privileges. Error - 1: Traceback (most recent call last):   File "/usr/share/powershell-empire/empire.py", line 11, in <module>     import empire.server.server as server   File "/usr/share/powershell-empire/empire/server/server.py", line 23, in <module>     import flask   File "/usr/lib/python3/dist-packages/flask/__init__.py", line 19, in <module>     from . import json   File "/usr/lib/python3/dist-packages/flask/json/__init__.py", line 15, in <module>     from itsdangerous import json as _json ImportError: cannot import name 'json' from 'itsdangerous' (/usr/lib/python3/dist-packages/itsdangerous/__init__.py) dpkg: error processing package powershell-empire (--configure):  installed powershell-empire package post-installation script subprocess returned error exit status...

Hide password in Command prompt

Image
@echo off set "psCommand=powershell -Command "$pword = read-host 'Enter Password' -AsSecureString ; ^     $BSTR=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword); ^         [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)"" for /f "usebackq delims=" %%p in (`%psCommand%`) do set password=%%p echo %password% This trick reads a password on Windows without echoing it to the screen by calling PowerShell from a batch file and using a SecureString prompt, so the typed characters do not appear in the console. Masking input is a small but useful courtesy in scripts that ask for credentials. Note that hiding the characters guards against shoulder surfing, not against the value being readable once it is in memory.

Build Jenkins Job Remotely | Fix: Error 403 No valid crumb was included in the request

Image
In case you are a newbie with Jenkins read through this article: http://com.puter.tips/2017/09/getting-up-and-running-with-jenkins.html Build Jenkins Job Remotely I have found two ways in which you can trigger a build on job remotely via scripting. Both methods are simple HTTP Get/Post requests, nothing fancy here. Along with these Requests we need to pass login credentials. Method 0: No protection enabled => This is the case when you are in a secure environment and have disabled all additional protection mechanism like CSRF (Method 1) and Authentication Token (Method 2). If this is the case then you can simply trigger a HTTP Request like this: 'http://username:password@jenkins_url:port/job/job_name/build' e.g. http://admin:pass@localhost:8080/job/job1/build

Jenkins: Trigger build remotely via script using Authentication Token

Image
Powershell: $acctname = "admin" $password = "password" $server = "localhost" $port = "8080" $jobName = "test02" $jobToken = "test02_authentication_token" $params = @{uri = "http://${server}:${port}/job/${jobName}/build?token=${jobToken}";             Method = 'Get';             Headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$(${acctname}):$(${password})"));}} Invoke-RestMethod @params

Jenkins: Trigger build remotely via script using crumb

Image
Python: import requests api_proto = 'http' api_url = 'localhost' api_port = '8080' api_job = 'test01' api_user = 'admin' api_pass = 'password' api_crumb = requests.get(api_proto + '://' + api_user + ':' + api_pass + '@' + api_url + ':' + api_port + '/crumbIssuer/api/json') if api_crumb.status_code == 200 :     api_crumb = api_crumb.json()['crumb'] resp = requests.post(api_proto + '://' + api_url + ':' + api_port + '/job/' + api_job + '/build', auth=(api_user, api_pass), headers={"Jenkins-Crumb":api_crumb}) if resp.status_code == 201:     print(api_job + ' was triggered successfuly..')