2018年3月21日 星期三

Telnet testing port workable

Install telnet tool on Windows;


telnet www.example.net 80

NetBIOS Over TCP/IP
The Windows 2000 implementation of NetBIOS over TCP/IP is referred to as NetBT . NetBT uses the following TCP and UDP ports:

UDP port 137 (name services)

UDP port 138 (datagram services)

TCP port 139 (session services)

Execute Remote batch file

假設該電腦
虛擬IP 192.168.1.66
該資料夾為 D:\B_Folder
該檔案為 A.exe
步驟:
1.擁有該電腦的 Administrator 權限(單機最高權限)
帳號: administrator 密碼: pwd
2.寫批次檔內容如下(1.bat):
10.104.67.237
10.104.69.235


net use \\192.168.1.66\d$\B_Folder "pwd" /user:"admini"
\\192.168.1.66\d$\B_Folder\A.exe

Working:
net use \\hostname\D$\users\david "pwd" /user:"administrator"
\\hostname\D$\users\david\123.bat

Execute PowerShell Script

直接在 PowerShell 的環境中
打入 D:\Learning\PowerShell\Ch02\GetFileShares.ps1
或是
先 cd D:\Learning\PowerShell\Ch02\
再打入 .\GetFileShares.ps1 (即便是在現行作用目錄區中,也要用 .\ )

在啟動 PowerShell 環境時
PowerShell -Noexit -command "D:\Learning\PowerShell\Ch02\GetWmiAndQuery.ps1"
參數
-Noexit:為了保持 PowerShell 的執行結果,能保留下來。
-command:為了是在啟動 PowerShell 時,一併載入指定的批次檔案。


PowerShell Scripts 如何執行?

http://pertonchang.blogspot.tw/2009/05/powershell-scripts.html

Run as Administrator

Open Powershell first:
Type PowerShell to enter a PowerShell session.
Once in the session:
Type Start-Process PowerShell -Verb RunAs and press Enter.
That will open a new Powershell process as Administrator.
------- OR -------
To do it all with only one line from the command prompt, just type:
powershell -Command "Start-Process PowerShell -Verb RunAs"

Curl and Invoke-WebRequest

Linux Bash:
Wroking: ***
curl -u "Account:PWD or API Token" 'http://FQDN:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'

Return:
Jenkins-Crumb:***************************

curl -X POST -u "Account:PWD or API Token" -H "Jenkins-Crumb:***************************" http://FQDN:8080/view/Operation/view/2_Stage/job/****/buildWithParameters?token=****&cause=trigger+by+shavlik+POC



PowerShell:

Start-Sleep -s 180
$JenkinsURL = "http://FQDN:8080"
$JobName = "view/Operation/view/2_Stage/job/****"
$JobToken = "****************t"
$Auth = "Account:PWD or API Token"
$Bytes = [System.Text.Encoding]::UTF8.GetBytes($Auth)
$Base64bytes = [System.Convert]::ToBase64String($Bytes)
$Headers = @{ "Authorization" = "Basic $Base64bytes"}
$CrumbIssuer = "$JenkinsURL/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,`":`",//crumb)"
$Crumb = Invoke-WebRequest -UseBasicParsing $CrumbIssuer -Headers $Headers
Write-Host $Crumb

$Regex = '^Jenkins-Crumb:([A-Z0-9]*)'
$Matches = @([regex]::matches($crumb, $regex, 'IgnoreCase'))
$RegCrumb = $Matches.Groups[1].Value
$Headers.Add("Jenkins-Crumb", "$RegCrumb")
Write-Host $Headers

$FullURL = "$JenkinsURL/$JobName/buildWithParameters?token=$JobToken"
Write-Host $FullURL
Invoke-WebRequest -UseBasicParsing $FullURL -Method POST -Headers $Headers

<End>

Refer:
Enable the URL job trigger:
https://www.nczonline.net/blog/2015/10/triggering-jenkins-builds-by-url/

CSRF Protection Explained
https://support.cloudbees.com/hc/en-us/articles/219257077-CSRF-Protection-Explained

Trigger Jenkins Builds Using PowerShell
https://www.smartfile.com/blog/trigger-jenkins-builds-using-powershell/

PowerShell Command
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/start-sleep?view=powershell-6


2018年3月19日 星期一

Connecting to a remote server through a VPN when the local network subnet address conflicts with a remote network



https://serverfault.com/questions/548888/connecting-to-a-remote-server-through-a-vpn-when-the-local-network-subnet-addres/835400#835400



added my desired destination server (192.168.1.100) to my routing table on my linux client via:
route add 192.168.1.100 dev tun0




route add -host 10.1.101.145 -interface [vpn interface name]

Windows cmd
route print

使用中的路由:
網路目的地                 網路遮罩         閘道          介面       計量
          0.0.0.0          0.0.0.0     10.1.187.254      10.1.184.23     10
       10.1.184.0    255.255.252.0            在連結上       10.1.184.23    266
      10.1.184.23  255.255.255.255            在連結上       10.1.184.23    266
:::

route add 192.168.99.0 mask 255.255.255.0 192.168.1.1


http://ctwivan.blogspot.tw/2010/08/windowsstatic-route.html
http://blog.xuite.net/ganpin917/home/49852565-%E9%9B%BB%E8%85%A6%E5%8F%8AServer+%E6%89%8B%E5%8B%95%E5%A2%9E%E5%8A%A0%E8%B7%AF%E7%94%B1


How-To: Route Print (Mac OS X)

https://www.unh.edu/it/kb/article/how-to-route-print-mac-os-x.html
netstat -nr

2018年3月8日 星期四

Configure apt-get behind proxy server for Ubuntu 14/15/16


$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:        16.04
Codename:       xenial


$ sudo vi /etc/apt/apt.conf

Acquire::http::Proxy "http://proxy_host:port";


To make this command permanent add it to ~/.bash.rc in your home directory:

vi ~/.bash.rc


Now Check and restart the updates:

root@ubuntu:~# apt-get  update
Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu xenial InRelease [95.8 kB]
:::
Okay


To use wget behind proxy

sudo vi /etc/wgetrc

https_proxy  = http://username:password@proxy:port
http_proxy = http://username:password@proxy:port
http_proxy = http://Domain\username:password@proxy:port # (in case of LDAP)
ftp_proxy = http://username:password@proxy:port
Uncomment 'use_proxy = on'


Now  try to use  wget

root@ubuntu:~# wget http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.4-1+trusty_all.deb
--2016-03-03 06:05:26--  http://repo.zabbix.com/zabbix/2.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_2.4-1+trusty_all.deb
Connecting to 10.133.80.35:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 2674 (2.6K) [application/x-debian-package]
Saving to: ‘zabbix-release_2.4-1+trusty_all.deb’

Okay

check_systemv1.1

 check_systemv1.1.bat 可用於電腦資產盤點 @echo off REM 後續命令使用的是:UTF-8編碼 chcp 65001 echo ***Thanks for your cooperation*** echo ***感謝你的合作*** timeout 1...