[WayBack] 🔎Julia Evans🔍 on Twitter: “ngrep: grep your network!… “
So this taught me a new tool and other new things:
Posted by jpluimers on 2021/02/16
[WayBack] 🔎Julia Evans🔍 on Twitter: “ngrep: grep your network!… “
So this taught me a new tool and other new things:
Posted in *nix, *nix-tools, Communications Development, Development, Internet protocol suite, Power User, Software Development, Wireshark | Leave a Comment »
Posted by jpluimers on 2021/02/16
I have these two little aliases in my toolbox:
alias "certbot-check-all-by-file=bash <(curl -fsSL https://raw.githubusercontent.com/srvrco/checkssl/master/checkssl) --location /etc/letsencrypt/live" alias "certbot-check-all-by-config=bash <(curl -fsSL https://raw.githubusercontent.com/srvrco/checkssl/master/checkssl) --server ISPconfig"
do not run just any script downloaded through curl. Plenty of reasons why this is dangerous:
- [WayBack] Detecting the use of “curl | bash” server side | Application Security
- [WayBack] One way “curl pipe sh” install scripts can be dangerous [proof of concept] / Jordan Eldredge: script content differs depending on user agent
- [WayBack] sean cassidy : Don’t Pipe to your Shell: scripts having different behaviour when executed partially
- [WayBack] Why using curl | sudo sh is not advised? – Stack Overflow:
You can proof your scripts against partial execution by putting the whole thing into the body of a function, and executing that function on the last line. If you know a script is defined like that, it’s exactly as secure as downloading and then executing some installer.
The first three can mostly prevented by using your own fork of the script repository, then checking each modification of the script, combined with ensuring your fork location does not throw tricks 1 or 2 on you.
That’s why I run the above alias only from a checkssl fork which I can inspect.
The aliases use quite a few tricks:
curl -fsSL https://raw.githubusercontent.com/srvrco/checkssl/master/checksslVia: [WayBack] The missing package manager for macOS (or Linux) — The missing package manager for macOS (or Linux)
bash <(curl -fsSL https://raw.githubusercontent.com/srvrco/checkssl/master/checkssl)Via: [WayBack] linux – Execute bash script from URL – Stack Overflow
bash <(curl -fsSL https://raw.githubusercontent.com/srvrco/checkssl/master/checkssl) --location /etc/letsencrypt/live
alias [WayBack] with double-quotes around the whole statement:alias "certbot-check-all-by-file=bash <(curl -fsSL https://raw.githubusercontent.com/srvrco/checkssl/master/checkssl) --location /etc/letsencrypt/live"
ISPconfig as the apache2 parameter value is not yet supported) domain configuration:alias "certbot-check-all-by-file=bash <(curl -fsSL https://raw.githubusercontent.com/srvrco/checkssl/master/checkssl) --location /etc/letsencrypt/live" alias "certbot-check-all-by-config=bash <(curl -fsSL https://raw.githubusercontent.com/srvrco/checkssl/master/checkssl) --server ISPconfig"
source instead of bashNote that an alternative alias is this one:
alias "certbot-check-all-by-file=(source <(curl -s https://raw.githubusercontent.com/srvrco/checkssl/master/checkssl) --location /etc/letsencrypt/live)"
However, that needs an extra set of parenthesis, otherwise you will get bumped out of your current shell.
The reason is that bash runs in a [WayBack] subshell, whereas [WayBack] source (and the equivalent [WayBack] “dot” command .) runs in the current shell, but the script performs a gracefull_exit or error_exit which end in an exit [WayBack] terminating the current shell.
The [WayBack] () parenthesis around the source command ensure it runs in a sub-shell.
In this case, you can still pass the --location /etc/letsencrypt/live parameters, as bash is the only shell allowing this: [WayBack] source – Passing variables to a bash script when sourcing it – Unix & Linux Stack Exchange.
Related [WayBack] Advanced Bash-Scripting Guide topics:
Related cURL options from [WayBack] curl – How To Use:
-f: [WayBack] -f, --fail(HTTP) Fail silently (no output at all) on server errors. This is mostly done to better enable scripts etc to better deal with failed attempts. In normal cases when an HTTP server fails to deliver a document, it returns an HTML document stating so (which often also describes why and more). This flag will prevent curl from outputting that and return error 22.
This method is not fail-safe and there are occasions where non-successful response codes will slip through, especially when authentication is involved (response codes 401 and 407).
-s: [WayBack] -s, --silent:Silent or quiet mode. Don’t show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.
Use -S, –show-error in addition to this option to disable progress meter but still show error messages.
See also -v, –verbose and –stderr.
-S: [WayBack] -S, --show-errors:When used with -s, –silent, it makes curl show an error message if it fails.
-L: [WayBack] -L, --location:(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with -i, –include or -I, –head, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it won’t be able to intercept the user+password. See also –location-trusted on how to change this. You can limit the amount of redirects to follow by using the –max-redirs option.
When curl follows a redirect and the request is not a plain GET (for example POST or PUT), it will do the following request with a GET if the HTTP response was 301, 302, or 303. If the response code was any other 3xx code, curl will re-send the following request using the same unmodified method.
You can tell curl to not change the non-GET request method to GET after a 30x response by using the dedicated options for that: –post301, –post302 and –post303.
Reminder to self: see if JSON output is viable. This commit might help.
–jeroen
Posted in bash, Conference Topics, Conferences, Development, Event, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2021/02/16
procedure Touch(var Argument);
begin
end;
I included the above code in my blog a long time ago (2014 in fact: Delphi: always watch the compiler Warnings), but never got around to explain the why and how I got it, why it works and why it will likely work forever.
Ever since the early Delphi days, there are three hints about “never used” of which the second often gets in the way during debugging:
(note that these %s only hold for non-managed types, which I also addressed in Why don’t I get the warning W1036 Variable “‘MyStrings’ might not have been initialized”… and Delphi 10.3 Rio got released; I’ll wait a while hoping to see more positive comments).
Usually the compiler is right, but sometimes it is not: [WayBack] Check your compiler warnings and hints. They may still be errors. | Shiftkey Software Blog
So once every while, you need this workaround:
The solution is to have a method with one untyped var parameter (a var parameter without any type: this way you can pass any field or variable to it) that just does nothing. Often I included only at the place I need it as this single line fragment: procedure Touch(var Argument); begin end;.
Former Delphi compiler engineer and Borland Chief Schientist Danny Thorpe handed this solution, I think it was during or around his famous BorCon99 in Philadelphi (and later BorCon2005 in San Jose) Reading Tea Leaves: The Fine Art of Debugging talk. The talk is not-online, but luckily there are notes and a StackOverflow post:
The session had seemingly simple things like this [WayBack] Shenoy At Work: Set Next Statement in Delphi? with the picture on the right.
I’ve seen teams making this method inline, but that voids it. Usually they do not see it as they already resolved the “never used” problem in another way.
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | 1 Comment »
Posted by jpluimers on 2021/02/11
Remember the screenshot on the right from yesterdays post Kristian Köhntopp explaining theories?
In the end, I:
I much more would have used the screenshot functionality of Google as described here by Terence Eden:
[WayBack] twitter – How to convert a tweet to image – Stack Overflow
Google has a secret screenshot API
For example, you can use it to get a screenshot of a tweet like this
At the bottom of that JSON response, you’ll see
"screenshot": { "data": "_9j_4AAQSkZJRgAB.....=", "height": 569, "mime_type": "image/jpeg", "width": 320 }You will need to Base64 decode it using the URL and Filename safe alphabet.
That will give you a JPG screenshot of the Tweet.
I was hoping for an on-line way, so I followed [WayBack] Google’s Secret Screenshot API – Terence Eden’s Blog.
The blog post pointed me to a Python based script ([WayBack] Python-Twitter-Hacks/websiteScreenshot.py at master · edent/Python-Twitter-Hacks · GitHub) but had no online way.
So I tried out a few on-line things myself that failed:
Can't convert Unable to decode Base64.“Invalid mime type: application/octet-stream“Then I found out the script was just a proof of concept with hard coded URL and filename.
So I forked the repository, and fixed the script basing it on Python 3.
More on that next week.
Related:
The Base 64 encoding with an URL and filename safe alphabet has been used in [12]. ...An alternative alphabet has been suggested that would use "~" as the 63rd character. Since the "~" character has special meaning in some file system environments, the encoding described in this section is recommended instead. ...This encoding may be referred to as "base64url". This encoding should not be regarded as the same as the "base64" encoding and should not be referred to as only "base64". ...This encoding is technically identical to the previous one, except for the 62:nd and 63:rd alphabet character, as indicated in Table 2. ...Table 2: The "URL and Filename safe" Base 64 Alphabet Value Encoding Value Encoding Value Encoding Value Encoding 0 A 17 R 34 i 51 z 1 B 18 S 35 j 52 0 2 C 19 T 36 k 53 1 3 D 20 U 37 l 54 2 4 E 21 V 38 m 55 3 5 F 22 W 39 n 56 4 6 G 23 X 40 o 57 5 7 H 24 Y 41 p 58 6 8 I 25 Z 42 q 59 7 9 J 26 a 43 r 60 8 10 K 27 b 44 s 61 9 11 L 28 c 45 t 62 - (minus) 12 M 29 d 46 u 63 _ 13 N 30 e 47 v (underline) 14 O 31 f 48 w 15 P 32 g 49 x 16 Q 33 h 50 y (pad) =
–jeroen
Posted in Apple, Development, Encoding, Home brew / homebrew, Mac OS X / OS X / MacOS, Power User, Software Development, Web Browsers | Leave a Comment »
Posted by jpluimers on 2021/02/11
[WayBack] One second code: Do YOU know how much your computer can do in a second? is a quiz version of the [WayBack] Numbers Every Programmer Should Know By Year.
[WayBack] About this game revealed it was made by 3 people curious in the speed of their hardware which – not surprisingly – has been relatively stable over the last decade or so.
Source code is at [WayBack] GitHub – kamalmarhubi/one-second: Fun performance game!
I bumped into it via these tweets:
I like games like this (ever played the The Deadlock Empire multi-threading game?), so I played the computers-are-fast.github.io tests, and learned a lot:
Posted in Conference Topics, Conferences, Development, Event, Hardware, Power User, Software Development | Leave a Comment »
Posted by jpluimers on 2021/02/11
I tried searching for F2084 Internal Error: MA1263 – Google Search which happened on a complete up to date Delphi 10.1 Berlin installation.
It came from a large unit testing application using truckloads of generic language constructs, and large unit uses cycles.
Could not find anything useful. The error disappeared after recompiling the same application:
–jeroen
Posted in Delphi, Delphi 10.1 Berlin (BigBen), Development, Software Development | Leave a Comment »
Posted by jpluimers on 2021/02/10
Document locations changed, so here are some links to newer and older documentation on LCID related things:
Creates a locale identifier from a language identifier and a sort order identifier.
LOCALE_INVARIANT – Windows applications | Microsoft Docs The locale used for operating system-level functions that require consistent and locale-independent results. LOCALE_USER_DEFAULT – Windows applications | Microsoft Docs: The default locale for the user or process.
VAR_LOCALE_USER_DEFAULT: [WayBack] VarUtils.VAR_LOCALE_USER_DEFAULT ConstantLOCALE_SYSTEM_DEFAULT – Windows applications | Microsoft Docs: The default locale for the operating system.LOCALE_CUSTOM* Constants – Windows applications | Microsoft Docs
LOCALE_CUSTOM_DEFAULT The default custom locale.
LOCALE_USER_DEFAULT.LOCALE_CUSTOM_UNSPECIFIED An unspecified custom locale, used to identify all supplemental locales except the locale for the current user.
LOCALE_CUSTOM_UI_DEFAULT The default custom locale for MUI.
The following are predefined language identifiers:
LANG_SYSTEM_DEFAULT. The operating system default language.LANG_USER_DEFAULT. The language of the current user.
// A locale ID is a 32 bit value which is the combination of a // language ID, a sort ID, and a reserved area. The bits are // allocated as follows: // // +-------------+---------+-------------------------+ // | Reserved | Sort ID | Language ID | // +-------------+---------+-------------------------+ // 31 20 19 16 15 0 bit // // WARNING: This pattern isn't always followed (es-ES_tradnl vs es-ES for example) // // It is recommended that applications test for locale names or actual LCIDs. // // Locale ID creation/extraction macros: // // MAKELCID - construct the locale id from a language id and a sort id. // MAKESORTLCID - construct the locale id from a language id, sort id, and sort version. // LANGIDFROMLCID - extract the language id from a locale id. // SORTIDFROMLCID - extract the sort id from a locale id. // SORTVERSIONFROMLCID - extract the sort version from a locale id. // // Note that the LANG, SUBLANG construction is not always consistent. // The named locale APIs (eg GetLocaleInfoEx) are recommended. // // LCIDs do not exist for all locales.
Using Persistent Locale Data
A globalized application often persists or transmits data, for example, time and date. When deciding how your application should handle data persistence, remember that data is not guaranteed to be the same from computer to computer or between runs of the application. This is true for both locales that ship with Windows and custom locales.
Design of the application must take into account a variety of locale-related data changes that can occur. For example:
- Currency symbols can change as countries adopt the Euro.
- Regional preferences can change. For example, the format d/m/y might change to the format m/d/y for a particular locale.
- The spelling of day names can change due to spelling reforms. Additionally, casing can change for month or day names.
Use Locale-Independent Formats for Storage and Data Interchange
An application that persists data should use locale-independent formats for storage and data interchange. Examples are hard-coded or standard formats; the invariant locale LOCALE_NAME_INVARIANT; and binary storage formats.
If persistent sorting data is required, the application must use the CompareStringOrdinal function. Remember that an invariant format does not remain invariant for sorting, only for locale and calendar data.
Use the User Default Locale for Data Presentation
To present persistent data, it is best for the application to reformat the data using the user default locale. Use of this locale allows user overrides. For more information, see LOCALE_USER_DEFAULT.
More Delphi related links:
Assume this code and default decimal separator is , :
var v: Variant; d: Double; begin v:= '0.12'; d:= v; ShowMessage(FloatToStr(d)); end;It will show 12 (not correct).
Now add this in the first line:
DecimalSeparator:= '.';It still gives the same result. If you enable debug dcu’s you will see that
the problem occurs in functionVarToDoubleAsString, which callsVarR8FromStrwithVAR_LOCALE_USER_DEFAULTas locale, so there is no chance to change it as I tried. What is the rationale behind this setup?Only workaround seems to either force users to have the correct default
locale or use d:= StrToFloat(v) instead of d:= v; This makes the code less readable.
OLECHAR string to a double value.–jeroen
Posted in Development, Internet, link rot, Power User, Software Development, Windows Development, WWW - the World Wide Web of information | Leave a Comment »
Posted by jpluimers on 2021/02/10
A long time ago, I write a question [WayBack] delphi – Should the compiler hint/warn when passing object instances directly as const interface parameters? – Stack Overflow in 2010.
It was marked by (now former) compiler engineer Barry Kelly [WayBack1/WayBack2] as bug:
It’s a bug. The conversion from instance to interface reference in
RunLeakCrashshould be to a temporary variable, keeping it alive for the duration ofRunLeakCrash.
Added to that was a comment that this has happened since at least Delphi 6, so I filed a bug WayBack QualityCentral Report #: 90482 The compiler should keep a hidden reference when passing freshly created object instances directly as const interface parameters.
Just for years later, it was marked with “As Designed” which means it is never going to be fixed, especially since in the mean time Embarcadero got rid of most the senior Delphi R&D team members and went down the path of hiring contractors.
The problem is that I run into the two manifestations every now and then, and it usually takes a long time debugging to zoom into the actual location of the spots.
This is the bug in the first manifestation (by now the root interface is IInterface instead of IUnknown, and you usually have an interface derived from it):
Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development, Undocumented Delphi | Leave a Comment »
Posted by jpluimers on 2021/02/09
The below configuration file haves [WayBack] ApexSQL Refactor – Free SQL formatter | ApexSQL produce quite OK formatted SQL, even for complex queries, not just for SQL Server.
So this is the second free tool I use from ApexSQL. The first one was ApexSQL, a free tool (SSMS add-in) for analyzing the execution plan of a SQL server query…
–jeroen
Posted in Database Development, Development, Software Development, SQL, SQL Server | Leave a Comment »
Posted by jpluimers on 2021/02/09
I linked to [WayBack] the Old New Thing a lot from my blog, but never put in a few links to the author of all those posts: Raymond Chen.
So here you go:
Recurring topics on his blog:
He is on some videos to, for instance [Archive.is] One Dev Question with Raymond Chen – Why Are There 4 Functions for Converting Strings to GUIDs | One Dev Minute | Channel 9 (the actual mp4 video file through Archive.is).
You can find many more via raymond chen site:channel9.msdn.com – Google Search
—jeroen
Posted in Development, Windows Development | Leave a Comment »