The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,437 other followers

nmap for Windows: ncat as a TCP client to servers

Posted by jpluimers on 2018/11/16

Downloads are from a bit cryptic page [WayBack] Download the Free Nmap Security Scanner for Linux/Mac/Windows via [WayBack] Windows | Nmap Network Scanning.

An alternative is to go to [WayBack] nmap.org/dist, then search for the bottom most files having .exe or .zip extensions.

It is much more modern than netcat (see some links on that below) and has elaborate documentation:

As a comparison some netcat links:

–jeroen

Posted in *nix, nmap, Power User | Leave a Comment »

Convert/adapt an old ATX Power Supply into a Bench Power Supply with (or without) 3D Printed Parts

Posted by jpluimers on 2018/11/16

An interesting idea, although I would slightly modify it so I can -12V and -5V as well and maybe other voltage combinations too:

They are based on these underlying links:

Note that some of the newer power supplies with 24-pin molex connectors do not give you -5V any more.

A few notes:

  • depending on the age, ATX supplies can get you these voltages: -12V, -5V, 0V, +3.3V, +5V, +12V
    • -12V and -5V have very limited currents
    • newer power supplies often do not have -5V (especially the ones having 24-pin connectors)
    • newer power supplies have limited +5V power, but higher +12V power
    • older power supplies have limited +12V power, but higher +5V power
  • always take pictures of all connectors and the wire colours connected to them before starting (especially before cutting any wires)
    • this allows you to find back:
      • non-standard wire colours
      • configurations not covered here
  • to get stable 12V, you need a 5V load of about 5W:
    • between RED (+5V) andBLACK (GND),
    • for instance with pin 3 and pin 4,
    • or over one of the molex/floppy connectors: pins RED-BLACK
    • as load,
      • use at least a 10V/10W resistor or 12v/10W halogen lamp
      • ensure they are cooled well
  • to get stable 12V, you need a 12V load of about 10W
    • between YELLOW (+12V) andBLACK (GND),
    • for instance with pin 10 and pin 17,
    • or over one of the molex/floppy connectors: pins YELLOW-BLACK
    • as load,
      • use at least a 20V/20W resistor or 12v/20W halogen lamp
      • ensure they are cooled well
  • if your power supply has a BROWN (+3.3VS),
    • then ensure it is connected to ORANGE (+3.3V)
      • as brown is the SENSING wire to check 3.3V is OK.
  • to turn the power supply on,
    • short GREEN (PWR_ON, pin 14) and BLACK (GND, pin 15)
  • to know when the power is on:
    • connect a LED via a resistor between GREY (PWR_OK, pin 8) and BLACK (GND, pin 7)
  • to know when there is mains power:
    • connect a LED via a resistor between PURPLE (+5VSB, pin 9: stand by) and BLACK (GND, pin 7 or pin17)
  • Wikipedia: ATX Power supply describes
    • PWR_OK (often called Power Good)
    • +5VSB (stand by)
  • read the specs of your power supply to understand how much current it can deliver on which lines
  • some more current information

Example for loads: https://www.youtube.com/watch?v=gKgziA46wFY; more on why you need them and how to choose:

With a few more modifications you can [WayBack] Convert a Computer Power Supply to a Variable Bench Top Lab Power Supply.

I will probably go for this solution as it is easier to swap power supplies.

–jeroen

Via: [WayBack] Nice recycling of an old ATX power supply with a 3D printed part and a few accessories and cables… – Jean-Luc Aufranc – Google+

 

Read the rest of this entry »

Posted in Development, Hardware Development | Leave a Comment »

Timestamp Generator / Converter – Timestampgenerator.com

Posted by jpluimers on 2018/11/16

I wish Google Search would return this when asking for “current time in ISO 8601”: [WayBackTimestamp Generator / Converter – Timestampgenerator.com

Type Value
Timestamp 1497872708
Server time 2017-06-19T11:52:55+00:00
ISO 8601 2017-06-19T11:45:08+00:00
RFC 2822 Mon, 19 Jun 2017 11:45:08 +0000
Day of the Week Monday
+1 Hour 1497876308
+1 Day 1497959108
+1 Week 1498477508
+1 Month 1500464708
+1 Year 1529408708

–jeroen

Posted in ISO 8601, LifeHacker, Power User | Leave a Comment »

Solution for Delphi – post-build event with multiple if/copy combinations only execute if first file does not exist – Stack Overflow

Posted by jpluimers on 2018/11/15

My solution in [WayBack] delphi – post-build event with multiple if/copy combinations only execute if first file does not exist – Stack Overflow is an addendum to my 2014 post Delphi prebuild/prelink/postbuild events.

Here we go:

Q

Given the bin\ directory inside the Delphi project contains the files Cert.pem and Key.pem, the below Delphi post-build event only copies both files if C:\Binaries\Cert.pem does not exist:

if not exist $(OUTPUTDIR)Cert.pem (copy bin\Cert.pem $(OUTPUTDIR))
if not exist $(OUTPUTDIR)Key.pem (copy bin\Key.pem $(OUTPUTDIR))

As soon as C:\Binaries\Cert.pem exists, the Key.pem file is never copied.

How can I solve this in the post-build event?

Edit: unlike my 2014 post, this is indeed possible using parentheses. See my answer below.

A

The problem with Delphi post-build events is that they are not batch files.

It means that statements that look like lines are being concatenated by the Delphi IDE into one big & ampersand separated statement. This ensures the commands are executed in sequence, as per Command Redirection, Pipes – Windows CMD – SS64.com:

commandA &  commandB      Run commandA and then run commandB

So this is the actual statement that gets executed:

if not exist $(OUTPUTDIR)Cert.pem (copy bin\Cert.pem $(OUTPUTDIR))&if not exist $(OUTPUTDIR)Key.pem (copy bin\Key.pem $(OUTPUTDIR))

The problem here is that now the second if is seen as a continuation of the “then” part of the first if statement: the second if never executes when the $(OUTPUTDIR)Cert.pem exists.

What helps is a little known feature that you can wrap each command inside parentheses. Normally this is to allow one command to span multiple lines (especially for if, and for..do loops), but it also works on one line.

Wrapping each line having an if statement inside parentheses ensures they become standalone statements not affecting the other lines, even if they are being concatenated with & ampersand separators.

In the dialog it looks like this:

(if not exist $(OUTPUTDIR)Cert.pem (copy bin\Cert.pem $(OUTPUTDIR)))
(if not exist $(OUTPUTDIR)Key.pem (copy bin\Key.pem $(OUTPUTDIR)))

That way, the IDE translates it into one statement:

(if not exist $(OUTPUTDIR)Cert.pem (copy bin\Cert.pem $(OUTPUTDIR)))&(if not exist $(OUTPUTDIR)Key.pem (copy bin\Key.pem $(OUTPUTDIR)))

Now it works as intended:

  • When $(OUTPUTDIR)Cert.pem exists but $(OUTPUTDIR)Key.pem does not, only $(OUTPUTDIR)Cert.pem is copied
  • When $(OUTPUTDIR)Cert.pem does exists but $(OUTPUTDIR)Key.pem does, only $(OUTPUTDIR)Key.pem is copied
  • when neither exist, both are copied
  • when both exist, neither are copied

I did not know this “trick” when writing my 2014 post Delphi prebuild/prelink/postbuild events, so I need to write an update for it.

Searching for batch file parentheses site:microsoft.com -site:social.technet.microsoft.com -site:answers.microsoft.com did not reveal it in the official documentation, but I am not surprised as it grew hysterically, instead of being designed. Or like the Old New Thing attributes h2g2:

Much like the universe, if anyone ever does fully come to understand Batch then the language will instantly be replaced by an infinitely weirder and more complex version of itself. This has obviously happened at least once before ;)

The best documentation I could find was at Parenthesis/Brackets – Windows CMD – SS64.com:

Parenthesis can be used to split commands across multiple lines. This can make code more readable. Variables will be evaluated for the code block just as if the command was a single line.

 (command)

 (
  command
  command )

Things that break inside parenthesis The CMD shell does not use any great intelligence when evaluating parenthesis, so for example the command below will fail:

IF EXIST MyFile.txt (ECHO Some(more)Potatoes)

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

dig: getting the list of root servers

Posted by jpluimers on 2018/11/15

For many dig queries, it helps to get the current list of root DNS servers.

Though the list is pretty static, occasionally it changes. While writing there were 13 of them and the most recent history report was in “RSSAC023: History of the Root Server System” at [WayBackwww.icann.org/en/system/files/files/rssac-023-04nov16-en.pdf.

So below are the steps to get an accurate list based on

First find out what the root servers are:

$  dig +noall +answer . ns | sort
.           106156  IN  NS  a.root-servers.net.
.           106156  IN  NS  b.root-servers.net.
.           106156  IN  NS  c.root-servers.net.
.           106156  IN  NS  d.root-servers.net.
.           106156  IN  NS  e.root-servers.net.
.           106156  IN  NS  f.root-servers.net.
.           106156  IN  NS  g.root-servers.net.
.           106156  IN  NS  h.root-servers.net.
.           106156  IN  NS  i.root-servers.net.
.           106156  IN  NS  j.root-servers.net.
.           106156  IN  NS  k.root-servers.net.
.           106156  IN  NS  l.root-servers.net.
.           106156  IN  NS  m.root-servers.net.

You should shorten this to $ dig +noall +answer . ns but that will not give you the TTL (how long the information will be cached before your DNS server refreshes it).

Now query at least 3 of these to get the actual list of root servers (I list only one statement, the rest is similar):

$ dig +noall +answer . ns @j.root-servers.net. | sort
.           518400  IN  NS  a.root-servers.net.
.           518400  IN  NS  b.root-servers.net.
.           518400  IN  NS  c.root-servers.net.
.           518400  IN  NS  d.root-servers.net.
.           518400  IN  NS  e.root-servers.net.
.           518400  IN  NS  f.root-servers.net.
.           518400  IN  NS  g.root-servers.net.
.           518400  IN  NS  h.root-servers.net.
.           518400  IN  NS  i.root-servers.net.
.           518400  IN  NS  j.root-servers.net.
.           518400  IN  NS  k.root-servers.net.
.           518400  IN  NS  l.root-servers.net.
.           518400  IN  NS  m.root-servers.net.

Compare the lists. If they are equal, then you’re done.

If not, then the internet is in trouble (:

When you want the A and AAAA records with IP addresses in addition to the NS records with names, then add +additional to your query:

dig +noall +answer +additional @j.root-servers.net. | sort
.           518400  IN  NS  a.root-servers.net.
.           518400  IN  NS  b.root-servers.net.
.           518400  IN  NS  c.root-servers.net.
.           518400  IN  NS  d.root-servers.net.
.           518400  IN  NS  e.root-servers.net.
.           518400  IN  NS  f.root-servers.net.
.           518400  IN  NS  g.root-servers.net.
.           518400  IN  NS  h.root-servers.net.
.           518400  IN  NS  i.root-servers.net.
.           518400  IN  NS  j.root-servers.net.
.           518400  IN  NS  k.root-servers.net.
.           518400  IN  NS  l.root-servers.net.
.           518400  IN  NS  m.root-servers.net.
a.root-servers.net. 518400  IN  A   198.41.0.4
a.root-servers.net. 518400  IN  AAAA    2001:503:ba3e::2:30
b.root-servers.net. 518400  IN  A   192.228.79.201
b.root-servers.net. 518400  IN  AAAA    2001:500:200::b
c.root-servers.net. 518400  IN  A   192.33.4.12
d.root-servers.net. 518400  IN  A   199.7.91.13
e.root-servers.net. 518400  IN  A   192.203.230.10
f.root-servers.net. 518400  IN  A   192.5.5.241
g.root-servers.net. 518400  IN  A   192.112.36.4
h.root-servers.net. 518400  IN  A   198.97.190.53
i.root-servers.net. 518400  IN  A   192.36.148.17
j.root-servers.net. 518400  IN  A   192.58.128.30
k.root-servers.net. 518400  IN  A   193.0.14.129
l.root-servers.net. 518400  IN  A   199.7.83.42
m.root-servers.net. 518400  IN  A   202.12.27.33

–jeroen

Posted in DNS, Internet, Power User | 1 Comment »

 
%d bloggers like this: