Friday, July 15, 2016

Using openssl to test SSL connection

Install openssl


Connect to server


openssl s_client -connect youserver.com:443 -showcerts


CONNECTED(00000164)
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify return:1
depth=1 C = US, O = GeoTrust Inc., CN = RapidSSL SHA256 CA
verify return:1
depth=0 CN = yourserver.com
verify return:1
---
Certificate chain
 0 s:/CN=yourserver.com
   i:/C=US/O=GeoTrust Inc./CN=RapidSSL SHA256 CA
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
 1 s:/C=US/O=GeoTrust Inc./CN=RapidSSL SHA256 CA
   i:/C=US/O=GeoTrust Inc./CN=GeoTrust Global CA
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
---
Server certificate
subject=/CN=yourserver.com
issuer=/C=US/O=GeoTrust Inc./CN=RapidSSL SHA256 CA
---
No client certificate CA names sent
Peer signing digest: SHA1
Server Temp Key: ECDH, P-521, 521 bits
---
SSL handshake has read 3100 bytes and written 558 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-SHA384
    Session-ID: ED280000CF500FD12BFD3637345041B63883D2BE08BB1E94B6E5DDBD18AD0C7A
    Session-ID-ctx:
    Master-Key: E0DCBBE41656F4118954F91B9E9B63BEF98576173C5BC48DF8B62446F0357700FC86C1BA6157EC7BCFCF
20EB485897B5
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1468613406
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)

Send HTTP commands

GET / HTTP/1.1
Host: youserver.com

Troubleshooting dlls

Confirming that dll exports a function


Open VS Command Prompt and run

dumpbin /exports yourDLL.dll


Microsoft (R) COFF/PE Dumper Version 11.00.61030.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file InnoSetupX2OUtils_d.dll

File Type: DLL

  Section contains the following exports for InnoSetupX2OUtils_d.dll

    00000000 characteristics
    5789203F time date stamp Fri Jul 15 13:41:19 2016
        0.00 version
           1 ordinal base
          38 number of functions
          38 number of names

    ordinal hint RVA      name

          1    0 0004B98D FWAddRule = @ILT+2440(_FWAddRule@36)
          2    1 0004C040 FWEnableRule = @ILT+4155(_FWEnableRule@4)
          3    2 0004B0FF FileSetFullControlForSID = @ILT+250(_FileSetFullControlForSID@8)
          4    3 0004C13A GUIDGenerateNew = @ILT+4405(_GUIDGenerateNew@8)
          5    4 0004BAFA GUIDIsCorrect = @ILT+2805(_GUIDIsCorrect@4)
          6    5 0004D0D0 GUIDispatchWaitingMessages = @ILT+8395(_GUIDispatchWaitingMessages@4)
          7    6 0004D1C5 GetLastX2OErrorMessage = @ILT+8640(_GetLastX2OErrorMessage@8)
          8    7 0004B67C IISAppPoolIdentityTypeFromString = @ILT+1655(_IISAppPoolIdentityTypeFromSt
ring@4)
          9    8 0004CAE5 IISAppPoolManagedPipelineModeFromString = @ILT+6880(_IISAppPoolManagedPipe
lineModeFromString@4)
         10    9 0004D76A IISFindApplicationPool = @ILT+10085(_IISFindApplicationPool@4)
         11    A 0004BF28 IISGetWebSiteId = @ILT+3875(_IISGetWebSiteId@8)
         12    B 0004B640 IISSetApplicationPool = @ILT+1595(_IISSetApplicationPool@36)
         13    C 0004D7A6 IISSetVirtualDirectory = @ILT+10145(_IISSetVirtualDirectory@24)
         14    D 0004BAA0 JSONtoVBADictionaryFromFile = @ILT+2715(_JSONtoVBADictionaryFromFile@8)
         15    E 0004C568 ProcessKillTreeByName = @ILT+5475(_ProcessKillTreeByName@8)
         16    F 0004CAF4 Reboot = @ILT+6895(_Reboot@0)
         17   10 0004C0A9 SecurityAccountNameFromSid = @ILT+4260(_SecurityAccountNameFromSid@20)
         18   11 0004B721 ServiceStopDependencies = @ILT+1820(_ServiceStopDependencies@4)
         19   12 0004C7F2 XMLChildElementAdd = @ILT+6125(_XMLChildElementAdd@12)
         20   13 0004CFBD XMLChildElementAddAsFirst = @ILT+8120(_XMLChildElementAddAsFirst@12)
         21   14 0004D3D7 XMLChildElementAddWithNamespace = @ILT+9170(_XMLChildElementAddWithNamespa
ce@16)
         22   15 0004C8F1 XMLCreateDocument = @ILT+6380(_XMLCreateDocument@4)
         23   16 0004BD16 XMLDocSetProperty = @ILT+3345(_XMLDocSetProperty@12)
         24   17 0004D440 XMLElementAdd = @ILT+9275(_XMLElementAdd@16)
         25   18 0004BCC1 XMLElementAddBefore = @ILT+3260(_XMLElementAddBefore@20)
         26   19 0004C32E XMLLoadDocument = @ILT+4905(_XMLLoadDocument@8)
         27   1A 0004D102 XMLNodeExists = @ILT+8445(_XMLNodeExists@12)
         28   1B 0004B9B0 XMLNodeFindChild = @ILT+2475(_XMLNodeFindChild@12)
         29   1C 0004C1DF XMLNodeGetAttribute = @ILT+4570(_XMLNodeGetAttribute@16)
         30   1D 0004D6A7 XMLNodeGetText = @ILT+9890(_XMLNodeGetText@12)
         31   1E 0004B429 XMLNodeMove = @ILT+1060(_XMLNodeMove@8)
         32   1F 0004CE78 XMLNodeRemove = @ILT+7795(_XMLNodeRemove@8)
         33   20 0004BCDF XMLNodeRemoveWithXPath = @ILT+3290(_XMLNodeRemoveWithXPath@8)
         34   21 0004B8FC XMLNodeReplaceWithXPath = @ILT+2295(_XMLNodeReplaceWithXPath@12)
         35   22 0004D373 XMLNodeSetAttribute = @ILT+9070(_XMLNodeSetAttribute@12)
         36   23 0004CBE4 XMLNodeSetText = @ILT+7135(_XMLNodeSetText@8)
         37   24 0004C978 XMLRelease = @ILT+6515(_XMLRelease@4)
         38   25 0004CB53 XMLSaveDocument = @ILT+6990(_XMLSaveDocument@8)

  Summary

        5000 .data
        2000 .idata
       22000 .rdata
        7000 .reloc
        1000 .rsrc
       9B000 .text
       4A000 .textbss


Depencency Walker



Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module (exe, dll, ocx, sys, etc.) and builds a hierarchical tree diagram of all dependent modules. For each module found, it lists all the functions that are exported by that module, and which of those functions are actually being called by other modules. Another view displays the minimum set of required files, along with detailed information about each file including a full path to the file, base address, version numbers, machine type, debug information, and more.
Dependency Walker is also very useful for troubleshooting system errors related to loading and executing modules. Dependency Walker detects many common application problems such as missing modules, invalid modules, import/export mismatches, circular dependency errors, mismatched machine types of modules, and module initialization failures.
Dependency Walker runs on Windows 95, 98, Me, NT, 2000, XP, 2003, Vista, 7, and 8. It can process any 32-bit or 64-bit Windows module, including ones designed for Windows CE. It can be run as graphical application or as a console application. Dependency Walker handles all types of module dependencies, including implicit, explicit (dynamic / runtime), forwarded, delay-loaded, and injected. A detailed help is included.



Thursday, July 14, 2016

Useful tools not related to development

Disk management

WinDirStat is a disk usage statistics viewer and cleanup tool for various versions of Microsoft Windows.

Friday, March 18, 2016

Build Script Interaction with TeamCity - Reporting Tests


Reporting Tests to TeamCity

To use the TeamCity on-the-fly test reporting, a testing framework needs dedicated support for this feature to work (alternatively, XML Report Processing can be used).
If TeamCity doesn't support your testing framework natively, it is possible to modify your build script to report test runs to the TeamCity server using service messages. This makes it possible to display test results in real-time, make test information available on the Tests tab of the Build Results page.

Supported test service messages

Test suite messages:
Test suites are used to group tests. TeamCity displays tests grouped by suites on Tests tab of the Build Results page and in other places.
##teamcity[testSuiteStarted name='suiteName']
<individual test messages go here>
##teamcity[testSuiteFinished name='suiteName']
All the individual test messages are to appear between testSuiteStarted and testSuiteFinished (in that order) with the same name attributes.
Suites may also be nested.
Test start/stop messages:
##teamcity[testStarted name='testName' captureStandardOutput='<true/false>']
<here go all the test service messages with the same name>
##teamcity[testFinished name='testName' duration='<test_duration_in_milliseconds>']
Indicates that the test "testName" was run. If the testFailed message is not present, the test is regarded successful.
duration (optional numeric attribute) - sets the test duration in milliseconds (should be an integer) to be reported in TeamCity UI. If omitted, the test duration will be calculated from the messages timestamps. If the timestamps are missing, from the actual time the messages were received on the server.
captureStandardOutput (optional boolean attribute) - if true, all the standard output (and standard error) messages received between testStarted and testFinished messages will be considered test output. The default value is false and assumes usage of testStdOut and testStdErr service messages to report the test output.
Icon
  • All the other test messages (except for testIgnored) with the same name attribute should appear between the testStarted and testFinished messages (in that order).
  • Currently, the test-related service messages cannot be output with Ant's echo task until flowId attribute is specified.
It is highly recommended to ensure that the pair of test suite + test name is unique within the build.
For advanced TeamCity test-related features to work, test names should not deviate from one build to another (a single test must be reported under the same name in every build). Include absolute paths in the reported test names is strongly discouraged.
Ignored tests:
##teamcity[testIgnored name='testName' message='ignore comment']
Indicates that the test "testName" is present but was not run (was ignored) by the testing framework.
As an exception, the testIgnored message can be reported without the matching testStarted and testFinished messages.
Test output:
##teamcity[testStarted name='className.testName']
##teamcity[testStdOut name='className.testName' out='text']
##teamcity[testStdErr name='className.testName' out='error text']
##teamcity[testFinished name='className.testName' duration='50']
The testStdOut and testStdOrr service messages report the test's standard and error output to be displayed in the TeamCity UI. There must be only one testStdOut and one testStdErr message per test.
An alternative but a less reliable approach is to use the captureStandardOutput attribute of the testStarted message.
Test result:
##teamcity[testStarted name='MyTest.test1']
##teamcity[testFailed name='MyTest.test1' message='failure message' details='message and stack trace']
##teamcity[testFinished name='MyTest.test1']
 
##teamcity[testStarted name='MyTest.test2']
##teamcity[testFailed type='comparisonFailure' name='MyTest.test2' message='failure message' details='message and stack trace' expected='expected value' actual='actual value']
##teamcity[testFinished name='MyTest.test2']
Indicates that the "testname" test failed. Only one testFailed message can appear for a given test name.
message contains the textual representation of the error.
details contains detailed information on the test failure, typically a message and an exception stacktrace.
actual and expected attributes can only be used together with type='comparisonFailure to report comparison failure. The values will be used when opening the test in the IDE.

Here is a longer example of test reporting with service messages:
##teamcity[testSuiteStarted name='suiteName']
##teamcity[testSuiteStarted name='nestedSuiteName']
##teamcity[testStarted name='package_or_namespace.ClassName.TestName']
##teamcity[testFailed name='package_or_namespace.ClassName.TestName' message='The number should be 20000' details='junit.framework.AssertionFailedError: expected:<20000> but was:<10000>|n|r    at junit.framework.Assert.fail(Assert.java:47)|n|r    at junit.framework.Assert.failNotEquals(Assert.java:280)|n|r...']
##teamcity[testFinished name='package_or_namespace.ClassName.TestName']
##teamcity[testSuiteFinished name='nestedSuiteName']
##teamcity[testSuiteFinished name='suiteName']

Interpreting test names

The Tests tab of the Build Results page allows grouping by suites, packages/namespaces, classes, and tests. Usually the attribute values are provides as they are reported by your test framework and TeamCity is able to interpret which part of the reported names is the test name, class, package as follows:
  • TeamCity takes the suite name from the corresponding suite message
  • if the reported test name starts with the suite name, it is truncated
  • the part of the test name after the last dot is treated as a test name
  • the part of the test name before the last dot is treated as a class name
  • the rest of the test name is treated as a package/namespace name

Source: https://confluence.jetbrains.com/display/TCD8/Build+Script+Interaction+with+TeamCity