
PHP filter functions
Filtering in PHP is super easy with the built in filter_var() function. Filtering is essential when taking in form input or applying logic to any set of data. This is especially crucial when sanitizing user input in order to prevent XSS and Sql injection attacks.
filter_var ( mixed$variable [, int $filter = FILTER_DEFAULT [, mixed$options ]] ) : mixed
Grab the code below to see how these functions work and head over to php.net and w3Schools for more information.
<?php
print "\n\n";
$int = 311;
$min = 1;
$max = 499;
if (filter_var($int, FILTER_VALIDATE_INT, array("options" => array("min_range"=>$min, "max_range"=>$max))) === false) {
print("Variable value is not within the legal range\n");
} else {
print("Variable value is within the legal range\n");
}
$int = 511;
if (filter_var($int, FILTER_VALIDATE_INT, array("options" => array("min_range"=>$min, "max_range"=>$max))) === false) {
print("Variable value is not within the legal range\n");
} else {
print("Variable value is within the legal range\n");
}
print "\n\n";
$ip = "2001:0db8:85a3:08d3:1319:8a2e:0370:7334";
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
print("$ip is a valid IPv6 address\n");
} else {
print"$ip is not a valid IPv6 address\n";
}
$ip = "192.168.2.1";
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false) {
print("$ip is a valid IPv6 address\n");
} else {
print"$ip is not a valid IPv6 address\n";
}
print "\n\n";
$url = "https://www.gunnard.org?q=b";
if (!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED) === false) {
print("$url is a valid URL with a query string\n");
} else {
print("$url is not a valid URL with a query string\n");
}
$url = "https://www.gunnard.org?q=b";
if (!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED) === false) {
print("$url is a valid URL with a query string\n");
} else {
print("$url is not a valid URL with a query string\n");
}
$url = "https://www.gunnard.org";
if (!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_QUERY_REQUIRED) === false) {
print("$url is a valid URL with a query string\n");
} else {
print("$url is not a valid URL with a query string\n");
}
print "\n\n";
$str = "<h1>Hello WorldÆØÅ!</h1>";
$newstr = filter_var($str, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
print $str ."<-- is what the string used to be before sanitization\n";
print $newstr;
What is the difference between GET and POST? {Developer Interview Questions}
Interview questions for developers are by nature “trick questions”. I say this because I have seen it too many times. On one hand, the question will be a complex narrative with multiple variables and things to consider, yet the answer is clear and straight forward. And on the other hand there is a very basic questions like this one “What is the difference between GET and POST?” where given a certain context, the answer… has layers.
The first layer to this answer is that GET and POST are HTTP Methods. These two, along with PUT, PATCH and DELETE are referred to as HTTP Verbs most commonly used in RESTful APIs. Here is a brief overview:
GET
The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
HEAD
The HEAD method asks for a response identical to that of a GET request, but without the response body.
POST
The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
PUT
The PUT method replaces all current representations of the target resource with the request payload.
DELETE
The DELETE method deletes the specified resource.
At this point, once could answer this question noting the differences between GET and POST is that GET is a request for a resource and POST is used to submit “something” to a resource. This is indeed true, but very surface level. Lets dig a little deeper.
A quick search on this topic return some valuable information from a little known site on the web, StackOverflow (/sarcasm). The certified answer does confirm our first findings (GET = request, POST = submit) but also adds an interesting note:
In addition to explaining the intended uses of each method, the spec also provides at least one practical reason for why GET should only be used to retrieve data:
Authors of services which use the HTTP protocol SHOULD NOT use GET based forms for the submission of sensitive data, because this will cause this data to be encoded in the Request-URI. Many existing servers, proxies, and user agents will log the request URI in some place where it might be visible to third parties. Servers can use POST-based form submission instead
https://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get
Here we have some new information on GET. Using GET in a form is not recommended if there is sensitive information because GET encodes the data in the Request-URI — which will appear in the serve logs and may be visible to third parties. Breaking this down, first, what is the Request-URI?
The Request-URI is a Uniform Resource Identifier and identifies the resource upon which to apply the request.
https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html
I hope that clears it up! Let’s see if they have an example for us.
GET http://www.w3.org/pub/WWW/TheProject.html HTTP/1.1
Ok, so it is a URL. Specifically it is the “?variable=some%20information” that you sometimes see in urls. GET submits data through the URI as a query string instead of within the body of the data. At this point I would also accept this as an answer.
Here are the takeaways:
- GET and POST are HTTP Methods.
- GET and POST are RESTful Verbs.
- GET sends a request and expects a result.
- POST sends data to be evaluated / stored.
- GET data is viewable in the URL and Logs.
As an interviewer, bonus points would be given if concepts such as input sanitization, sql injection, language specific handling (i.e. $_REQUEST in php) were brought up.
I hope this gives you (interviewer or interviewee) some clear information on what should be expected as an answer to this classic question. Let me know your thoughts on GET and POST in the comments and what interview questions you want covered.

Free PHP Malware and Security scanners [Part 1]

Exakat
Exakat is a tool for analyzing, reporting and assessing PHP code source efficiently and systematically. Exakat processes PHP 5.2 to 7.4 and 8.0 code, as well as reporting on security, performance, code quality, migration.
–Exakat docs
Static analysis of code is a great tool to use whether for unit testing or in this case security vulnerabilities and malware infestations. Security and malware may fall into the same “family” of concerns, in terms of programming they are two distinct issues and need to be treated as such. Security vulnerabilities ( see previous article on OWASP Top 10 ) deal with analyising a codebase for unused methods, insecure databases, SQL injections, XSS opportunities etc.. Malware detection looks at the codebase for unintended code that has been maliciously injected without the developers knowledge.
Exakat takes a three tier’d approach to code analysis. First an AST (Abstract Syntax Tree) is created from the codebase. The AST is a representation of every construct within the source code and how they are syntactically related. Next Exakat takes this tree and traverses it looking for broken and unused relationships, documented security flaws and overall statistical data on the code. Finally, Exakat produces useful charts and data for your team to review in order to improve the codebase.
In order to use Exakat some requirements are needed.
Basic requirements :
- exakat.phar, the main code.
- Gremlin server : exakat uses this graph database and the Gremlin 3 traversal language. Currently, only Gremlin Server is supported, with the tinkergraph and neo4j storage engine. Version 3.4.x is the recommended version, while version 3.3.x are still supported. Gremlin version 3.2.* are unsupported.
- Java 8.x. Java 9.x/10.x will be supported later. Java 7.x was used, but is not actively supported.
- PHP 7.4 to run. PHP 7.4 is recommended, PHP 7.2 or later are possible. This version requires the PHP extensions curl, hash, phar, sqlite3, tokenizer, mbstring and json.
Optional requirements :
- PHP 5.2 to 8.0-dev for analysis purposes. Those versions only require the ext/tokenizer extension.
- VCS (Version Control Software), such as Git, SVN, bazaar, Mercurial. They all are optional, though git is recommended.
- Archives, such as zip, tgz, tbz2 may also be opened with optional helpers (See Installation guide for optional tools).
OS requirements : Exakat has beed tested on OSX, Debian and Ubuntu (up to 20.04). Exakat should work on Linux distributions, may be with little work. Exakat hasn’t been tested on Windows at all.
For installation, curl or wget, and zip are needed.

HTTP/3 and IETF QUIC coming to a chrome near you
But first…. Are we really at http/3? and what the heck is IETF QUIC? QUIC is a new networking transport protocol that combines the features of TCP, TLS, and more. HTTP/3 is the latest version of HTTP, the protocol that carries the vast majority of Web traffic. HTTP/3 only runs over QUIC.
Why do we need this? Blame the xennials. Not really, but really. The vast majority of web traffic that will be carried over this is the top sites today: netflix, twitch, tiktok, Facebook.
Read more on the chrome blog.

Practice typing by typing a book
TypeLit.io is a fantastic idea. This site will let you improve your typing skills by typing actual books. No more typing about foxes and jumping. Typelit will let you choose from 1984, Alice in Wonderland and even the King James Bible.

Android on Linux
ANDROID IN A BOX is here to bring any Android OS to your Linux box.
Android in a box (Anbox) is a brand new player to the scene making use of containers instead of emulators to bring Android to Linux. Here’s a quick video of it in action.
To get started with Anbox your system needs to first use snaps. There official statement on other distro methods is “We do not officially support any other distribution method of Anbox at the moment but there are community made packages for various distributions (e.g. Arch Linux).” These community packages are not listed on their site but they do have an irc and Telegram channel.
The installation of Anbox consists of two steps.
- Install necessary kernel modules
- Install the Anbox snap
The kernel modules needed are only available for Ubuntu in a PPA on Launchpad. Community involvement is encouraged to bring Anbox to your favorite distro!
Starting with Ubuntu 19.04 binder and ashmem are now build with the standard Ubuntu kernel (>= 5.0) and you don’t have to install the modules from the PPA anymore.
In order to add the PPA to your Ubuntu system please run the following commands:
$ sudo add-apt-repository ppa:morphis/anbox-support
$ sudo apt update
$ sudo apt install linux-headers-generic anbox-modules-dkmsThese will add the PPA to your system and install the anbox-modules-dkms package which contains the ashmem and binder kernel modules. They will be automatically rebuild every time the kernel packages on your system update. After you installed the anbox-modules-dkms package you have to manually load the kernel modules. The next time your system starts they will be automatically loaded.
$ sudo modprobe ashmem_linux
$ sudo modprobe binder_linuxNow you should have two new nodes in your systems /dev directory:
<code>$ ls -1 /dev/{ashmem,binder}
/dev/ashmem
/dev/binder</code>More detailed info on the kernel modules can be found on the Anbox kernal module install page.
Installing the Ambox snap
$ snap install --devmode --beta anboxor if not currently logged into the ubuntu store
$ sudo snap install --devmode --beta anbox–devmode is required as the Anbox snap is not yet fully confined.
As a side effect of using –devmode the snap will not automatically update. In order to update to a newer version you can run:
$ snap refresh --beta --devmode anboxInformation about the currently available versions of the snap is available via:
$ snap info anboxUninstall information can also be found on their install page.
Install applications
Installation applications into the Android container provided by Anbox we currently use the sideloading functionality Android provides. For this you need to have the Android Debug Bridge (ADB) installed on your host system.
If you’re running Ubuntu or Fedora you can install ADB easily:
# On Ubuntu
$ sudo apt install android-tools-adb
# On Fedora
$ sudo dnf install android-toolsAnbox does not provide any functionality to retrieve Android applications. There are sites such as APKMirror or APKPure that provide links for popular applications and games. Once you have the APK package for the application you can install it into the Android container with the following command:
$ adb install my-app.apkIf the Anbox container is not running yet you can start it with loading the application manager application:
$ anbox.appmgrAnbox looks very promising and more information on install and configuration can be found on their doc site.

Escaping strings in Bash using !:q
This amazing Bash trick comes from Pascal Hirsch on Twitter. It goes like this: Enter a line of Bash starting with a # comment, then run !:q on the next line to see what that would be with proper Bash escaping applied.
bash-3.2$ # This string 'has single' "and double" quotes and a $
bash-3.2$ !:q
'# This string '\''has single'\'' "and double" quotes and a $'
bash: # This string 'has single' "and double" quotes and a $: command not found
How does this work? James Coglan explains:
The
!character begins a history expansion;!stringproduces the last command beginning withstring, and:qis a modifier that quotes the result; so I’m guessing this is equivalent to!stringwherestringis"", so it produces the most recent command, just like!!does

PHP 8.0 Release Candidate Available
“The PHP team is pleased to announce the eighth testing release of PHP 8.0.0, Release Candidate 1.”
This RC can be found on the official release site
| php-8.0.0rc1.tar.bz2 | 2020-09-29 22:46 | 13M | ||
| php-8.0.0rc1.tar.bz2.asc | 2020-09-29 22:46 | 866 | ||
| php-8.0.0rc1.tar.gz | 2020-09-29 22:46 | 16M | ||
| php-8.0.0rc1.tar.gz.asc | 2020-09-29 22:46 | 866 | ||
| php-8.0.0rc1.tar.xz | 2020-09-29 22:46 | 10M | ||
| php-8.0.0rc1.tar.xz.asc | 2020-09-29 22:46 | 866 |

Windows server vulnerability.
WINDOWS SERVER VULNERABILITY REQUIRES IMMEDIATE ATTENTION
.
This has been posted on /r/sysadmin on Reddit:
CVE-2020-1472 Netlogon Elevation of Privilege Vulnerability
byu/ugus insysadmin
Twitter post explaining it:
https://twitter.com/RyanLNewington/status/129344415164462694…
Blog post explaining it:
https://www.tenable.com/blog/cve-2020-1472-zerologon-vulnera…
POC:
https://infinitelogins.com/2020/09/15/abusing-cve-2020-1472-…

Docker: Remove all images
I’ve been using Docker a lot at work for development. This leads to a pile-up of images on the server. In order to clear them out I made this handy little script.
!#/usr/bin/bash
docker rm -f $(docker ps -a -q)
docker rmi -f $(docker images -q)This will remove all images even attached ones on your system. Be aware that running this on production or a shared development environment will result in tears and loss of joy.
