concept file in category security

appears as: files, file, The file, file, files
The Art of Network Penetration Testing

This is an excerpt from Manning's book The Art of Network Penetration Testing.

The directory names aren’t necessarily set in stone.  The part I want to highlight the most is organizing your notes, files, scripts & logs in a methodical manner that follows along with the methodology you’re using to conduct your penetration test. 

Figure 2.3 Directory structure you created

Next, place a file called ranges.txt inside of the discovery folder. This file should contain all of the IP address ranges in your engagement scope, each on their own line. nmap can read this file as a command-line argument that comes in handy for running different types of nmap commands. For the Capsulecorp engagement I’m just going to place 10.0.10.0/24 inside the discovery/ranges.txt directory because that is the only range I have in my scope.  On a typical INPT your ranges.txt file will likely contain several different ranges.  If you’re following along with the Capsulecorp-pentest environment from GitHub then you’ll want to use the IP range 172.28.128.0/24.

Listing 9.1 Creating a new SSH key pair
~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/pentestkey    #A
Enter passphrase (empty for no passphrase):    #B
Enter same passphrase again:
Your identification has been saved in /root/.ssh/pentestkey.
Your public key has been saved in /root/.ssh/pentestkey.pub.
The key fingerprint is:
SHA256:6ihrocCVKdrIV5Uj25r98JtgvNQS9KCk4jHGaQU7UqM root@piccolo
The key's randomart image is:
+---[RSA 2048]----+
| .o     .       |
| oo. . +         |
|Eo .o.=o.       |
|o.++ooo.o        |
|+@o...+.S.      |
|Bo*. o.+o        |
|.o.. .*+.      |
|. o  oo +o.     |
| ..o. .. o.     |
+----[SHA256]-----+

By default, all commands entered into a bash prompt are logged inside a .dot file named .bash_history, which is located inside the home directory for all users. You can return to the home directory for the current logged-in user by typing the cd ~/ command. There you can view the contents of the .bash_history file by typing the command cat .bash_history. If the file is too long to view in a single terminal window you can page through it, one screen at a time by typing cat .bash_history | more, which will pipes the output of the cat command into the more command, so you can use the space bar to scroll through the output one terminal window at a time. You can see an example of what this would look like in listing 9.9. Trying this on your own Linux VM will result in different output of course because you have typed different commands.

API Security in Action

This is an excerpt from Manning's book API Security in Action.

The diagram produced in steps one to three is known as a dataflow diagram, and an example for a fictitious pizza ordering API is given in figure 1.6. The API is accessed by a web application running in a web browser, and also by a native mobile phone app, so these are both drawn as processes in their own trust boundaries. The API server runs in the same datacenter as the database, but they run as different operating system accounts so you can draw further trust boundaries to make this clear. Note that the operating system account boundaries are nested inside the datacenter trust boundary. For the database, I've drawn the database management system (DBMS) process separately from the actual data files. It's often useful to consider threats from users that have direct access to files separately from threats that access the DBMS API because these can be quite different.

The code to create the TokenStore
interface and Token
class is given in listing 4.4. As in the UML diagram, there are just two operations in the TokenStore
interface for now. One for creating a new token, and another for reading a token given its ID. You'll add another method to revoke tokens in section 4.6. For simplicity and conciseness, you can use public fields for the attributes of the token. Because you’ll be writing more than one implementation of this interface, let’s create a new package to hold them. Navigate to src/main/java/com/manning/apisecurityinaction
and create a new folder named token
. In your text editor, create a new file TokenStore.java in the new folder and copy the contents of listing 4.4 into the file and click save.

The Dockerfile in the listing downloads the latest release of H2, verifies its SHA-256 hash to ensure the file hasn’t changed, and unpacks it. The Dockerfile uses curl to download the H2 release and sha256sum to verify the hash, so you need to use a base image that includes these commands. Docker runs these commands in a container running the base image, so it will fail if these commands are not available, even if you have curl and sha256sum installed on your development machine.

To reduce the size of the final image and remove potentially vulnerable files you can then copy the server binaries into a different, minimal base image. This is known as a Docker multistage build and is useful to allow the build process to use a full-featured image while the final image is based on something more stripped down. This is done in listing 10.1 by adding a second FROM command to the Dockerfile, which causes Docker to switch to the new base image. You can then copy files from the build image using the COPY --from command as shown in the listing.