星期四, 9月 21, 2017

How to find out user id and SID mapping


PsGetSid
https://docs.microsoft.com/zh-tw/sysinternals/downloads/psgetsid

Security Identifier(SID): GetSID of a user,object using Registry, WMIC, PowerShell
https://blogs.msdn.microsoft.com/gaurav/2014/06/03/security-identifiersid-getsid-of-a-userobject-using-registry-wmic-powershell/


wmic useraccount where (name='administrator' and domain='gauravtestMachine') get name,sid

Name           SID
administrator  S-1-5-21-1976753858-2077894621-3616986626-500




星期二, 9月 19, 2017

MQ client failed to connect qmgr with 2539 error

https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.0.0/com.ibm.mq.tro.doc/q045390_.htm

2539 (09EB) (RC2539): MQRC_CHANNEL_CONFIG_ERROR

ExplanationAn MQCONN call was issued from a client to connect to a queue manager but the attempt to establish communication failed. Common causes of this reason code are:(1) The server and client cannot agree on the channel attributes to use.(2) There are errors in one or both of the QM.INI or MQCLIENT.INI configuration files.(3) The server machine does not support the code page used by the client.
注意﹕非常容易忘記(3)也可能造成無法連線, 從error 的文字訊息不易想到

星期二, 9月 05, 2017

How can I test if my server supports a specific SSL protocol?

1. Linux command line tool:
openssl can help you test which SSL protocols your server is configured to use.
openssl

If a protocol is enabled, the openssl s_client command will wait for input (or Control-D).
If the protocol is disabled, openssl will report an exception similiar to the one reproduced below:
21112:error:1407F0E5:SSL routines:SSL2_WRITE:ssl handshake failure:s2_pkt.c:428:

Openssl examples:
openssl s_client -connect ihshostname:443 -ssl2
openssl s_client -connect ihshostname:443 -ssl3
openssl s_client -connect ihshostname:443 -tls1

#openssl s_client -connect www.google.com:443 -ssl3
CONNECTED(00000003)
23569:error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number:s3_pkt.c:293:

#openssl s_client -connect localhost:1414 -cipher ECDHE-RSA-DES-CBC3-SHA

#openssl s_client -connect localhost:1414 -showcerts

#openssl ciphers  ==> 列出openssl可用的cipher名稱, 以:分隔

**** perl one liner 可用在此處, 把原本用:分隔不易查看的資訊, 改以每筆一行的方式列出

#openssl ciphers|perl -ne 's/:/\n/g;print'


2. online website check tool
https://www.ssllabs.com/ssltest/

3. standalone test tool (TestSSLServer)
https://www.bolet.org/TestSSLServer/

4. IHS v8 or above version command:
Windows:
httpd -t -D DUMP_SSL_CONFIG
Linux:
apachectl -t -D DUMP_SSL_CONFIG

http://publib.boulder.ibm.com/httpserv/ihsdiag/ssl_questions.html#sslprotsupptest


5. use nmap to help to verify which cipherspec is supported by SSL server

nmap --script ssl-enum-ciphers -p port_number ip_address

# nmap --script ssl-enum-ciphers -p 1477 localhost
Starting Nmap 7.70 ( https://nmap.org ) at 2019-06-03 10:56 CST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00018s latency).
Other addresses for localhost (not scanned): ::1

PORT     STATE SERVICE
1477/tcp open  ms-sna-server
| ssl-enum-ciphers:
|   TLSv1.0:
|     ciphers:
|       TLS_RSA_WITH_AES_128_CBC_SHA (rsa 1024) - A
|       TLS_RSA_WITH_AES_256_CBC_SHA (rsa 1024) - A
|     compressors:
|       NULL
|     cipher preference: server
|   TLSv1.2:
|     ciphers:
|       TLS_RSA_WITH_AES_128_CBC_SHA256 (rsa 1024) - A
|       TLS_RSA_WITH_AES_256_CBC_SHA256 (rsa 1024) - A
|       TLS_RSA_WITH_AES_128_GCM_SHA256 (rsa 1024) - A
|       TLS_RSA_WITH_AES_256_GCM_SHA384 (rsa 1024) - A
|       TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (secp256r1) - A
|       TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 (secp384r1) - A
|       TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (secp256r1) - A
|       TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (secp384r1) - A
|     compressors:
|       NULL
|     cipher preference: server
|_  least strength: A

Nmap done: 1 IP address (1 host up) scanned in 1.63 seconds

Ref:

SSL 相關的測試工具
https://www.qa-knowhow.com/?p=3888

SSL handshake concept:
https://support.f5.com/csp/article/K15292








星期四, 8月 24, 2017

Perl — Calculate timing difference in microseconds

Time::Piece has been in core since 5.10.


use Time::Piece;

sub str2time {
    my ($str) = @_;
    $str =~ s/(\.[0-9]+)?\z//;
    my $fraction = $1 || 0;
    return Time::Piece->strptime($str, '%Y-%m-%d %H:%M:%S')->epoch + $fraction;
}

my $t1 = str2time('2013-12-27 13:28:14.975952');
my $t2 = str2time('2013-12-27 13:28:16.345667');

printf "difference: %f\n", $t2 - $t1;


This can be used to analyze the trace for performance issue.

Note:

||                              if the left operand is true, the right operand is not even evaluated.
\z                             Match only at end of string
 ?                             Match 1 or 0 times
$var =~ s/A/B/       
把變數 $var 內的第一個A子字串整個代換成B子字串。特別注意第一部份(A)為RE, 但第二部分(B)僅為字串

http://irw.ncut.edu.tw/peterju/perl.html

$str =~ s/(\.[0-9]+)?\z//   => 表示將小數點後(含小數點)的部分用空字串取代, 也就是移除
$fraction = $1 || 0            => 表示若有找到小數點後的部分, 即把其值copy 給fraction, 不然就設為0




星期二, 8月 15, 2017

星期四, 8月 03, 2017

How to specify the path of the JVM core dump file

https://jazz.net/forum/questions/147686/is-it-possible-to-customize-the-java-core-and-heap-dump-paths-for-tomcat

http://www-01.ibm.com/support/docview.wss?uid=swg21255223

http://www-01.ibm.com/support/docview.wss?uid=swg21242497

Using dump agent to specify the path of the core file

example:

-Xdump:system:file="/path/core.%Y%m%d.%H%M%S.%pid.%seq.dmp"



How to install ComputerCraft mod for Minecraft

https://www.youtube.com/watch?v=pMrxzffJVs8


1. launch the Minecraft with the correct version
2. download and install corresponding forge version mod
3. download the corresponding ComputerCraft mod and put it into the mod subfolder

*** 不同版本的mod 可能無法被不同版本的Minecraft forge載入, 要搭配正確版本
例如: 1.7.10 的Minecraft 就要搭配同樣是1.7.10 的forge 和 ComputerCraft

若要切換不同版本, 也要記得移除mod目錄下的檔案, 換成正確版本的mod 檔案