Can a BIOS or UEFI infection transfer to other storage drives without the OS presence? I am already aware that a BIOS or UEFI malware "activate" only in the OS environment. Is it possible though that a spread mechanism be activated without the presence of the OS, so that it would infect plugged storage drives (IDE, SATA or USB) with the same or other malware ?

Example Scenario:

Let a PC with BIOS or UEFI infected, connected to three storage drives: a SATA disk, an IDE disk and a USB thumb drive.

The PC is started and after a while it prints
"No Boot Device". During that stage, could any storage drive be infected by the BIOS or UEFI malware ?

NOTE: I concentrate to the fact that BIOS or UEFI can copy data (malicious or not) to other drives, irrespective of the storage drives file system. If data cannot be copied to other drives while trying to boot, so does the malware (I guess).

There is always an operating system, albeit not necessarily a complex one. The BIOS is an OS in the strict sense of the term: it provides access to hardware through an hardware-independent API. The boot code for an OS (or some malware that pretends to be that boot code) uses the BIOS-provided API to read (and possibly write) bytes from the hard disk.

Theoretically, nothing would prevent a piece of malware, installed as "boot code", to use the BIOS to observe the hard disks, locate "infectable" files, and infect them. This would imply making sense of the filesystem structure, which is normally a job performed by the "big" OS (the Windows or Linux or OS X or whatever). If the malware wants to do this by itself, then it must include the code to do so, which can be bulky, or take some non-negligible development effort. Thus, while it is possible, it can be expected that most malware authors, being no less lazy than any other developer, will prefer to avoid it. Booting a "normal" OS and then using its facilities to access files is easier.

The GNU GRUB bootloader is not at all malware; it is a piece of software whose job is to leverage the low-level disk accesses of the BIOS to locate and load in RAM the core elements of an operating system to boot (e.g. the kernel in the case of Linux). As part of its functioning, it includes support for many filesystems. A malware author who wants to locate and infect files in filesystem from a "bootloader" environment would probably reuse parts of GRUB. In any case, GRUB demonstrates that filesystem support code can be compact enough to fit in the constraints of the bootloading environment.


SQL injection using brute force? I am studying about cyber defense lately for fun and found about a proposed method that as I understand it performs automated SQL injection using brute force by training a model. At some point it says that if it receives input:
"SELECT * FRO" it will find that the next letter is "M" and then if it receives HTTP Status 200 is good and if HTTP Status 500 is bad and will train the algorithm accordingly.
Since the query "SELECT * FROM" is not complete how it will receive HTTP Status 200?
and also how this attack in general can be mitigated?
You can find the source here:
https://cesena.github.io/2018/02/27/weaponizing-machine-learning/#Other-resources
As an approach appears very interesting and would like to read an explanation from specialists.

This is less a question about SQL Injection itself, and more about this particular ML based implementation.
I had to look at the code to understand better what the author tried to say with this example. To the best of my understanding, this is actually a very poor example, let's remember this is a tool supposed to execute SQLi attacks, not to just run queries. In this example it seems like it is just trying to learn how to interact with a SQL server, what it's not really it's purpose, a much better(and realistic) example would be something along the lines of:
Input: SELECT * FROM example_table WHERE id == {ACTUAL USER INPUT}
Output: 1 // 200
Output: m // 500
…
Output: 1 OR 1==1 // 200

The "Input" field is actually the server-side query, and the Output would be the parameter the tool would give to the website.
Again, this is based on what I got from his article and code, to really understand what is happening I recommend you read the full code in the repository and try to run it yourself.
As I mentioned in my comment, there's nothing special about this attack defense-wise, it is just an attempt at a better way to explore SQL injection vulnerabilities, the vuln itself is still the same, meaning that to mitigate it you would just need to sanitize user input before inserting it in your SQL query.
You said you are studying the subject for fun, so in case you are not too familiar with SQLi attacks this and this page should help you get a better grasp at what causes it, and how to fix it.


Strange spam to my IG and email with my secret information I got strange email recently telling that i have an affair and it listed my visited cities with my boyfriend last year. Also threaten to share my relationship with others. Something that bother me that I do not share my trips to others and it list down all the cities I visited. I have checked that I do not keep my itineraries but recently submitted my scan of my passports to online visa lodgement of oz.

I am frustrated why it knew my details like spying me? And it sends the email to my office email.

Previously I receive the same threatening message and comments in my instagram. And I put the IG story telling it is a "spambot attack" and then a strange account occured and tag me and others that it is not a spambot attack and keep posting and tagging me having an affair.

I had checked the story who viewed the story, no strange accounts vieweing it.

Is it possible that my phone is being spied? And what is the logic behind listing my visited cities?

Really frustrated and afraid for next attack and how to stop this? Two times attack in two different accounts telling the same story. For information currently i use oppo.

More information

The spam in instagram and email is using well constructed english. I am from a country that english is not primary language, maybe only people educated overseas can speak that kind of english.

In the instagram post that telling me its not attack, it refer me as my account name e.q @myaccount not my name

In the email it opened the email with Hi there, and then followed by english introductory and list down the countries using ordered list.

I am not exactly sure if any one of the following is the case or not but I will try to suggest you many possible cases:

Your Gmail account :
One might find it amusing how much user data Google services log and use for providing various features. Try to remember if you had ever forgotten to log out from your gmail account when you had used it on a device not exactly yours or less trustworthy. If so you should immediately go to Google account security tab and check your logins and log yourself out of all the unknown sessions.

Your mobile phone :
Attackers or those who use smart tools such as metasploit etc. can create a payload app and use some social engineering skills to install it on target device. These apps are surprisingly strong enough to track your geographic locations and other such critical details. You should check your oppo phone's installed apps and find out those apps which are suspicious and uninstall them after finding details. Do not think that there are only those apps which are visible in the menu of your phone.

Social media check-ins :
Now this might sound funny but there are people who are so obsessed with instantly updating their statuses and check-ins on social media such as Facebook ,Instagram, etc. Make sure you are not one of them and remove unknown people from your friend list, maybe the one who is attacking you is one of them.
A close person to you :
Don't just deny this entirely based on your affection for your close people. Many a times there are people who do this just to scare you out and with no serious bad intention like a prank or some sort of that stuff. Make sure this is not the case with you.
Further reading 1
Further reading 2
Further reading 3


Why should password authentication require sending the password? Why do systems that do password authentication actually send the password over the wire?

Why not just have the server issue a challenge, and have the client append append that challenge to the password and reply with its SHA256 hash, to protect against MITM leakage of the password?

Is there any benefit to actually sending the password? (It seems e.g. SSH does this? Why?)

The reason for passwords sent either in plain text or hashed are mainly historical. In the old days when we used dumb terminal over serial lines (70's to 80's), only plain text solutions were possible. Well One Time Password like S/Key also existed but you needed the hardcopy list with you...

Then came the era of PC, Windows and Lan Manager. Microsoft fellows knew that ethernet networks were too easy to spy, so they decided to only exchange challenges. The counterpart was that is was necessary to store the password in an invertible form on the server.

The usage of crypto became more popular with SSL, and many protocols were adapted to use encrypted channels (HTTP -> HTTPS for example). And admins re-discovered the benefits of only storing hashes on their servers: if the password database is compromised, you have plenty of time to change the passwords.

That's the reason why best practices are nowadays to exchange password over encrypted channels and store salted hashes on servers, and why other practices have existed...


Distributed Denial Of Service Attack Mitigation Is there any way in which you can stop a DDoS attack(or any measure that you can take), if the packets sent by the attacker look like normal traffic?

I got the question on an interview (how would you block a DDoS attack if the malicious traffic looks like the normal traffic?) and I didn't knew how to answer.

Thank you very much!

In most cases, it is very hard to mitigate DDoS attacks on your own. Most banks and large companies will engage the service of professional DDoS mitigation service providers. The latter will detect anomaly traffic patterns and reroute all traffic to their scrubbing centers for filtering out the bad traffic. The following filtering-based mechanisms are commonly used to mitigate such attacks:

1) Whitelisting recognized IP addresses. e.g., if your company is located in the US and so are most of your clients located, then it could be reasonable to filter our network traffic coming from other parts of the world during an attack so that most of your clients can still be able to access your service.

2) Blacklisting traffic coming from known "spammer" regions.

3) Deploy progressive challenge mechanism like CAPTCHA to prove that the traffic came from a human source and not some program.

4) Rate limiting by destination IP address. Each IP address is only allowed to send a fixed number of requests and the rest of the requests will be simply dropped.

5) Signature-based anomaly detection and subsequent IP blocking. Even if the malicious packets appear normal, there could still exist distinct patterns in the overall traffic. e.g., an average user will only send traffic continuously for 5 minutes each day but the traffic sent by the attacker just keep coming in for long periods of time.

And finally, increase your network resources to survive the attack or temporary rent extra cloud-based resources to "absorb" the attack. Such a counter measurement is used by DDoS Mitigation service providers like Incapsula, Akamai and Verisign to prevent themselves from becoming victims.


Is it possible to tell when a remote bitmessage client is creating new messages? One StackExchange answer mentioned bitmessages can be traced, another said it is fully anonymous. The second link seems to cite Wikipedia but a user points out that this anonymous concept doesn't exist in the whitepaper.

My concept is that you could have a tremendous number of bitmessage clients that track the IP address of every client that sends you a message. You keep a log of the IP address and the messages it sent. It seems like you could make a bet of fairly high accuracy whether a client is originating new messages when it's repeatedly the first source of a message you have not seen before.

Is there some aspect of the bitmessage protocol that makes this impossible?

PyBitmessage has random forwarding delays, so you won't necessarily receive a message first from the node it originates on. You can increase your anonymity by using a passive node (not accepting connections), and/or by using Tor. Of course, we're trying to improve anonymity even for the rest of the cases.


Web browsing on Windows 2008 R2 terminal server (RDS): IE9 or Firefox? Flash or not? I'm setting up a Windows 2008 R2 terminal server which users will connect to from thin clients. Since the thin clients don't have a web browser I need to allow users to surf from their terminal session.

With security in mind: what browser should I install for the users? Do I stick with IE9 or should I look at Firefox?
Also, with regards to the Flash player, should I avoid installing it and inform the users that "Due to security Flash sites will not work" end of story?

RDS is just an "exported display". You should allow exactly what you would allow the users to do if they could sit in front of the machine itself. The most important thing is to keep the browser (and the OS) always up to date. For that, I tend to prefer Chrome, which updates itself transparently and can often do so without requiring any browser restart.

I recommend avoiding Flash for a usability reason: Flash is used to animate things, and, as such, implies considerable data traffic between the computer and the display mechanism -- in your case, over the network which connects the thin clients with the base system. Playing a Flash-based video over RDP can be a frustrating experience (of course, if you use gigabit ethernet, this is not necessarily an issue).


Convert PDF to plain text, remove malware? Take a PDF, copy all, paste it into a .rtf document in textedit, --> make plain text. will this remove/nullify any malware from/in the pdf? In other words, if I open the PDF on one machine and convert it to plain text as such and then send the plain text file to a new machine, the new machine will not be at risk?

As soon as you open the pdf to copy its contents and if there is any exploit present then it is going to be executed if your pdf reader is vulnerable to arbitrary code execution vulnerability and then it will infect all your files or just open up a backdoor.

If you want to open such pdf files create a virtual machine using vmware workstation put the pdf in a virtual machine and open it with updated pdf reader like adobe reader then you can copy and paste the contents of pdf file in a guest machine (virtual machine) to a text file in a host machine.

If you copy the (text) contents of pdf into a txt file then the malware won't work.


Spam issue regarding security on gmail app I have been getting a ton of spam email, so I looked at one of them.
I did not click anything, or download anything. However there was a spammy image with option to click on (as they always do).

Would this infect my device or the app (gmail app)? I am using an android phone. All I did was look at a spam email.

As checks, I ran the play protect from the play store. In addition, I have run several malware detection apps: Malwarebytes,Bitdefender etc. I have also looked at the installed apps and used safe mode just in case. Nothing has turned up, all of these steps show no infections.

My questions: a) is there any other check I should do? b) does just looking at an email cause an infection on the gmail app on android?

b) does just looking at an email cause an infection on the gmail app on android?

Just laying your eyes at the contents of spam or malicious email is safe.

Like looking or hovering your mouse over,

a picture with a link embedded
at a malicious attachment
a plain URL

  a) is there any other check I should do?

There's nothing to do because there was nothing that happened. Don't worry.


Summer Internships (for IT/Security/Networking?) I know these are a common thing to do during the Summer semester for Computer Science students at large companies like Facebook, Apple, Google, etc.

Are there similar internships available for IT students? Security? Hell, even Business? I'm majoring in Management Information Science (Bachelors, falls under Business Administration) and will soon have two Associates (Information Systems Security and Network Design).

From what I could tell in my short search, the most "security sounding" one @ FB still wanted you to be a amazing programmer, something which I am not.

I applied for this: https://www.facebook.com/careers/department.php?dept=interns&req=a2KA0000000La9gMAC Probably a bit of a stretch, but whatever, can't hurt!

Found this, seems like a good candidate for AFTER graduation w/ Bachelors: https://www.facebook.com/careers/department.php?dept=grads&req=a2KA0000000LbVuMAK

You may have luck selling the idea to a small company with no ITSEC department. I would sell the idea as a IT Security best practice analysis. Suggestions would be to analyze their public website for issues found in the OWASP top 10. Evaluate how their server and workstation management/policies/procedures stack up against the SANS TOP 20. Evaluate the effectiveness of their IDP/IDS if they have it; Install and configure SNORT if they don't. It would be a win-win situation.


How does Malware use Unregistered Domains I just finished reading that the WannaDecryptor malware was querying an unregistered domain. I thought it was connecting to its command and control server. Is this correct?

It is my understanding that if a program of any sort attempts to connect to a server at an unregistered domain, the connection will fail - due to IP address resolution failure. Is that correct? If it's not, how is the IP address of the domain resolved? Or am I missing something?

Was the malware communicating with the control server using a configured unregistered domain? If it was, how was it able to without using DNS registration for IP address resolution?

As the previous two mentioned the malware wasn't connecting to the unregistered domain name. The unregistered domain was a technique that was supposed to be used to prevent analysis of the malware.

Often times when malware researchers are picking apart malware they do so in a virtual machine. The way certain virtual machines resolve domain names result in unregistered domain names being considered "resolved" to applications running on the VM. Advanced malware authors know this and so before they infect the machine they will often attempt to connect to random unresolved domain names. If these domain names get resolved then it signals to the malware that it is functioning on a virtual machine. If it detects this then it will abort and refuse to infect the machine. This makes analyzing the malware more difficult.

In the case of the WannaCry malware the author attempted to create a similar countermeasure, but did so incorrectly. He hard coded the unregistered domain names. So once the researcher pointed the hard coded domain name to a DNS sink all the infected computers thought they were infecting a VM. So instead of starting the encryption process the malware just exits to prevent further analysis.

Had the author randomized the domain name check, registering the domain name would have done nothing.


Why are Certificate Revocation List periodically renewed? While studying a security course I have been asked this very question:
Why are CRL periodically renewed, even if there are no new revoked certificates to add to the list?

Honestly I can't find the answer, if any of you could be so kind to shed some light on it, I would be very grateful.

A couple fundamental things:

The basis of a CRL is a promise for a certain time period.  That means a begin time and an end time.  Once a CRL is made and signed, it can't be changed, so it lasts as long as it lasts, and can't be trusted after that.
In essence, you won't know until you check.  A CRL in its regular form is one big list.  You can't assume that the size is an indication... the verifier needs to know exactly what Certificates are no longer trusted.  So you need to get a fresh copy, either way.  There's no protocol to check "is this the same as my old one?"
The primary implementation of CRLs is not "go get one when you need it" but "get it ahead of time, and check it when you need to".  Which means the primary mechanism of distribution is a series of file downloads and caches.  A server won't know that the next CRL is exactly the same as the currently expiring CRL until it has both - at which point, if you have a fresh version, why check?  If what is needed is a "ask when you need it, you'll always have access" sort of structure, then go with OSCP.
The basic rationale of validity dates is to allow PKI implementers to make a conscious decision about how long to go with out checking in with the CRL issuer.  A PKI system will make this decision on an issuer by issuer basis, in accordance with the risk to the system and the patterns of its intended usage.  It's a real challenge - the validity should be commensurate with the risk - how long are the system protectors willing to wait before checking in on the "known bad guy" list?
There's a basic premise here that I relate to looking at canned food in a submarine...  the expiration date is how long the manufacturer promises that it'll be OK to consume it.  Can you eat meat a day after the expiration date?  Yep.  In fact, day-old meat is a way better option than starving to death.  What about meat that is 6 months past it's expiration date?  Well.. what kind of germs are you up against?  There's a real possibility that this food will make you sicker than not eating anything (just shutting down and doing no transactions until you have a fresh CRL).  In all cases, the reality is, you weight the cost of doing business against the risk of uncertain data.

NOTE:  All this applies only to a general, garden variety CRL.  There's a number of alternate formats out there.  Last I looked, they were all proprietary... but it's been a while...  some of these alternate formats can work differently, as they all aim at simplifying.


Does the OWASP Zed Attack Proxy project have a list of all the vulnerabilities it tries to find/exploit? I'm trying to compile a list of vulnerabilities that ZAP tries to find when you run the "Active Scan" in ATTACK mode on a webapp. Does this list exist in the documentation anywhere? If it also has a list of all the inputs that it tries that would be very helpful.

We have a FAQ for that :) https://github.com/zaproxy/zaproxy/wiki/FAQzaptests

ZAP has a built in set of 'input vectors' https://github.com/zaproxy/zap-core-help/wiki/HelpUiDialogsOptionsAscaninput but you can also define your own via script input vectors: https://github.com/zaproxy/zap-core-help/wiki/HelpAddonsScriptsScripts


How to provide personal User Page after User already signed up without Password? I created a small website where participants can sign up with some data (name, email, birthdate, ...) but they don't have to set username and password.

After a while it would be useful to provide some kind of overview site (of course not showing any personal data) for each user. Now I'm thinking about different ways how to achieve that:

Sending each User a personal URL (e.g. mydomain.com/LongAndUniqueRandomString) without login.

PRO: less overhead, less security issues
CON: public to everyone else who has the URL, bad email practice as it behaves like phishing spam

Implementing a login and send each User his personal (predefined) Password

PRO: better privacy
CON: no save way to provide password to the user

What do you think?

The traditional method of allowing users to enter a username and password works, changing it for a substitute of you creating their password or, worse yet, eliminating it completely seems a little odd.

I'd recommend sticking to the traditional way, however, in the interest of the question;

Sending them a unique URL

This has so many follow up questions, but on the assumption they sign up and you send them a url to access their "data"?  There isn't a safe security practice behind this, you've said it yourself, if someone else obtains that URL, you have a compromised user. Stick to the tried and tested method of correctly implementing sessions into your website. Along with minimizing security breaches, you also then won't need to worry about hosting X amount of separate web pages for every single user.

Sending user a password

I don't see any reasoning behind why you'd want to do this, letting a user set up their own password is no additional effort to you at all. Sending them a password runs the risk of emails being compromised.

What happens if an email that's meant for "Jake" is compromised by "John". I don't think Jake would be all that forgiving because you insisted on creating, and sending a password to him.

If you do insist on using these types of methods, be very, very careful with regards to what information you store and what kind of information users can access.


How to verify secure erasure of Android and Apple mobile devices I'm aware of how to securely sanitise and verify the sanitisation of data from both HDDs and SSDs, but mobile phones complicate this due to being there a lot of proprietary layers standing between the storage hardware and the interface.

Specifically, how can one verify the data sanitisation of Android and Apple mobile devices respectively? Is there no alternative to letting the factory reset run and hoping that the device's implementation of it doesn't fail?

Factory reset, open the camera and let it record a movie in the highest resolution and framerate until all storage is full, factory reset again.

The first factory reset will free all storage, then the movie recording will fill up all the storage, overwriting everything, and the second factory reset deletes everything again. This will work even on older phones where the storage was not encrypted.

It's overkill on the newer versions, because the storage is fully encrypted and the first factory reset will destroy the key.


Is it an security issue to have php change files? I wrote some code which uses information from database to change content of various files and write something back to database afterwards.

This code is completly written in php and gets executed when I call a specific URL (htaccess protected).

Are there any security issues this could bring with it?

Probably relevant php-functions I use:

mysqli_connect($servername, $username, $password, $dbname);
file_get_contents($url);
file_put_contents($url);

Those are the functions I could imagine being "unsafe".

All the files are on a server!

Any tips on making it safer?

EDIT - trying to give important information: So I have a virtual server with various domains. On one of the domains there are folders with various files, which are created by a software. Those are different xml files and a html file. I need to add codesnippets to all html files.

For some other reasons I have the filepath stored in a database. My file (complete php) has a function which gets called when I open the url where my file lays and uses the above said functions to change the html files. There is nothing users can add or anything. My file just gets triggered --> executes --> changes files/db and gives me some information back on as html, whether the changes were successfull or not.

So my full "work procedure" is like this:
create the html+xml with my software
upload those on ftp
put some information into database
call the url to the php-file to edit my html-file(s) in the way I want.

As mentioned I have to enter htacces before I can trigger the php-file and only me and collegues know the path to the php-file.

Rely on path for security sounds weak to me (they can be cached by proxies), as relying on .htaccess (they can be ignored if admin fails the configuration when rebooting the server).

If the path & content written to HTML files are using the DB, and the PHP cannot alter it, then it sounds less attackable, but it could still be:

• If the wrote HTML file is the same as the read one (in-place file changes), then cascading calls may have unexpected results (ie: multiple string replacement/decoding)

• If one access the FTP, they can write anything to HTML files. That's normal. But here, when one access the DB, then they can write anything to HTML files too (and maybe to any file). So you made a new entrypoint, so new security challenges.

Why doing so online? There, you should do your trick on a local network, take the resulting files back, and push them to the real prod server. You won't have any risk of someone calling your build-script from the Internet. Otherwise, rely on non-homemade solutions. Take open-source ones, which will still have the same kind of flaws, but already analyzed & fixed by hundreds of people.


Does MDC integrity protection matter in symmetric encrypt/decrypt of local files? I'm configuring scripts etc. to use GPG's symmetric mode to encrypt some files on my home desktop system.

When I want to edit one of the encrypted files I decrypt it and pipe it into my editor and then, to save it, the editor writes the file to a named pipe and the following encrypts it:-

echo $pwd | gpg --symmetric --passphrase-fd 0 epipe

The named pipe, epipe, is then deleted.

This works fine as long as there is no MDC integrity checking but if I use --force-mdc or use a cipher which defaults to doing MDC then the above command hangs.  I think this must be because gpg is trying to read the MDC string from epipe as well as the file data and the read blocks.

If I want to use AES256 does turning off MDC integrity checking actually make things any less secure?  These are files used only by me, never exchanged with others.

The original issue was because I was trying to (reasonably) securely feed both the password/phrase and the file to be encrypted into gpg.

I have a simple script that decrypts the file and feeds it (via a pipe) into my editor.  The script asks for the password and it's kept in an environment variable, not perfect but better than putting it in a file or something.

The difficult bit was, after editing the file, to get both the file and the password back into gpg.  It turns out that gpg is actually quite well behaved and where it says " Only the first line will be read from file descriptor n." in the --passphrase-fd description it really means it.  Thus you can simply prepend a line containing the password to the file to be encrypted and pipe both into gpg, as follows:-

<password + file> | gpg --symmetric --passphrase-fd 0 >file.gpg

I can now have:-

s2k-cipher-algo AES256
s2k-digest-algo SHA512
s2k-count 65011712

in my gpg.conf file such that MDC integrity protection is used (because it comes with AES256) and so I don't get any warnings.

I edit these files on my own home desktop computer so using an environment variable for the passphrase is reasonably OK and I have avoided saving anything in a file anywhere that might persist if something dies on the way.


AES-256 OR RSA-2048 for web application security? I'm developing a web application with a database backend using Django that will be accessed from the Internet. The database will contain sensitive information and I'd like some advice on the approach I should use to secure the data.

Approach 1: Encrypt the information using RSA-2048 bit encryption using the public key on the Internet facing server. Then on a separate server (not internet facing) have another web application to decrypt the data using the private key.

Approach 2: Encrypt the information using AES-256 bit encryption with a single encryption/decryption key on the Internet facing server.

Which approach is securer and more efficient?

The issue I see with approach 1 is that although it's a belt and braces approach the data that is submitted via the web application can't be modified by the end user once it's been encrypted. And the issue I see with approach 2 is that since the encryption/decryption key is on a single server, if the web application was compromised so would the data.

I'd appreciate your advice.

Thanks in advance.

About efficiency: symmetric encryption (like AES) of comparable security level will always be faster than asymmetric one (like RSA).

Because of this (and since RSA needs some random padding to be secure, meaning the ciphertext is a bit larger than the plaintext), the usual way to use RSA (if you have to encrypt more than about the key size) is to generate a random key for a symmetric algorithm, encrypt that key with RSA, encrypt the plaintext with this random key, and store the encrypted key together with the plaintext.

So, your selection is actually between:

RSA (with public + private key) together with AES (or some other algorithm, but let's stay simple)
only AES (with a secret key)

The actual cryptography here is not a point where an attacker will get any advantage - both AES and RSA (with the given key size) are secure enough to resist brute-force attacks.

If you are using only symmetric encryption, of course the encrypting server needs this key, and if compromised, this key can be used to decrypt the data in the database. There is not really a way around this.

If you are using asymmetric encryption, your encrypting server could have only the public key – but this is only a viable option if this webapp server never needs to decrypt the data again, i.e. for write-only data. Do you really have such data? (It can be modified after submitting, but only by overwriting it, not by first reading it, changing and writing back.)

Also, since this is using a public key for encrypting, there is nothing hindering an attacker with database access from changing the data to something else. If an attacker somehow gets access to the database (he shouldn't, of course), it is not that complicated to derive the public key from the encrypted data. Having that, the attacker can simply insert new records into the database, or overwrite old ones, and your decrypting process (with the private key) has no chance to see the difference. To avoid this, have the writing process also sign the data (with the private key of a different key pair), where the reading process can verify these signatures.

You can have a second server to decrypt it for the first one on demand, but this will not be much safer than having the first one do it itself (only that you can simply cut it off when you remark the attacker's presence).

So, to completely estimate your security, it is necessary to first have an attack model (i.e. against which attacks do you want to be sure), then you can judge which variant protects better.

  I want to be sure the Internet facing server doesn't get attacked.

The encryption of the database by itself does not open (or close) any attack route on the web server, either way. They are only different if some attacker finds another security hole in your web application, and gets access to the web server.


Need advice on Cryptography digital files project I have to choose a topic for my end-of-year school project and I need some advice. I was thinking of implementing an online tutorial materials (digital files) project. I have been researching on cryptography and read on symmetric/asymmetric algorithms. Here is what I have so far:

The idea is about creating a system where the course materials are
encrypted and can only be decrypted by students of the school's
course.
The course materials would be encrypted by AES algorithm
and the AES key would be stored in the database.
The database would contain a table with column "Course" and its corresponding "AESKey".
Since it is insecure to store the AES key in clear text, I was then
thinking about encrypting it using a password-derived key PBKDF2 (the
password of which would be given to the students by the teacher of
the course).
Then, when the student requests the materials, he
would simply provide the password for that course and then be able
to retrieve the AES key.

What do you think of that idea? AND how can I make it more secure? Because I wanted to achieve some kind of multi-factor authentication but then it would be infeasible to give smart cards to each and every student! I had been thinking of encrypting the AES key using RSA public/private key method, but then there will be lots of students (Do I create a public/private key pair for each student? Sounds infeasible...) Or maybe there is some other way I can implement the RSA encryption scheme in there? I will be using C# as implementation language.

Your advice is most welcome! Thanks

My first question is why? What are you hoping to gain by encrypting the material and adding the overhead of managing and distributing encryption keys?

There needs to be clear goals defined before you can assess whether the proposed solution is adequate. While your general plan sounds like you have thought it out a bit, it isn't clear what you are trying to do. For example, if all of this encryption is because of some kind of digital rights concerns over the learning materials, then I suspect you are only creating additional overhead and inconvenience for both teachers and students with no real benefit.

Issues you need to think about

How do you verify the student you plan to give the password to is really the student?

How do you know the student won't share their password with others?

How do you know the person using the password is the person they claim to be?

The key problem you have is in establishing levels of assurance. This is almost impossible to do using just passwords. There are lots of other questions - for example, after the student has obtained the materials and used the key to decrypt them, what stops them from distributing the unencrypted versions? Once this occurs, how would you identify who released them?

It seems to be you are facing two problems - establishing identity level of assurance (nearly impossible when based solely on a password) and DRM - nearly impossible without imposing considerable inconvenience on the users.

Sorry if this is sound really negative. I'm not trying to be discouraging. However, from the short description you provided, I think you need to get some greater clarity on exactly what the objectives or business case is you are trying to solve and exactly what the constraints are


How secure is IDology's ExpectID (as used on airbnb)? To quote https://travel.stackexchange.com/a/72476/2928

  I entered the last four digits of my SSN and provided basic DOB and full name. Then it asked me three security questions that only I would know the answers to. For example, it asked where I was in 1989-1990 and it asked where something was.

  From this article airbnb is using an identity verification service from a company called IDology. This company provides a service to verify your identity:

    Derived from information in public data records, ExpectID IQ serves up
    non-intrusive, intelligent questions relating to that person’s history
    such as something involving a previous address or an associated
    person.

How secure is that? I imagine a resourceful attacker could answer anyone's verification questions, either by researching the public records herself, or subscribing to IDology and requesting question-answer sets on the target until the same question came up.

The service almost certainly checks the person's credit file with one or more major reference agencies and may check some government ID verification databases too, depending on the jurisdiction and if the government there provides such a service. (I.E confirming a SSN / National Card ID Number / Driving license / Passport is valid with the details supplied.)

If you could answer someone else's security questions in the manner described, you could probably apply for credit in their name or file fake tax returns on their behalf to get large tax refunds. You could also apply for jobs as them and pass some forms of employee background screening.

Similar questions are asked by the credit reference agencies when signing up for online credit monitoring services, which provide the user with almost every piece of information held on the person by credit reference agencies.

If a fraudster can sign up for online credit monitoring or take out large loans / mortgages / get into vetted jobs as a person then they are probably screwed over much more than if a fake account got created on AirBnB. (though admittedly having to prove that you weren't responsible for fraudulently renting out a room that didn't exist or murdering a guest would be pretty bad)

It may be possible to put fraud notices or a 'freeze' on your credit file which could provide some some protection against this (along with other types of identity theft and fraud).


Defence against promiscuous detection techniques As an attacker,how do I prevent people from finding out that my NIC is in promiscuous mode?
For test like ARP and DNS how do I defeat the users detection mechanism?

There is a possibility that Promiscuous mode can be detected by another device on the network!
You can/must configure your sniffer tool/software so that it doesn't allows to detect if you are in promiscuous mode. For that you have to configure your sniffer tool so that your machine doesn't reply to the packets/requests that are usually used to detect the Promiscuous mode.
Here you can read how the promiscuous mode can be detected.
However the feature, that not to respond to the requests(Specially crafted packets to determine the promiscuous mode) depends if it is available in your sniffer tool.


Why no different languages in passwords? We have been told when creating passwords/ keys etc. to never use a different language/ characters to create it ie. a mandarin keyboard, as it greatly decreases the strength. Why is this?

In general, there is no reason not to use arbitrary characters in a password, unless the system processing the password does something stupid with them (like removes them completely, leaving an empty password).

In the bad old days of language-specific character sets, there was always the risk that a password with non-ASCII characters might stop working when you switched to a different computer, because it was encoding those characters differently.  But nowadays everybody's pretty much standardized on Unicode as the standard universal character set, so that reason rarely applies unless dealing with old legacy systems.

(Of course, we still have different ways of encoding Unicode characters into bytes, like UTF-8, UTF-16-LE/BE, UCS-32, etc., but at least those are generally pretty well under the receiving program's control, as opposed to depending on the user's OS and/or terminal settings like charset selection used to be.  And, honestly, UTF-8 is becoming pretty well established as the standard Unicode encoding for I/O purposes, even if some software may use other encodings internally.)

In fact, using characters from a wider pool makes it harder for an attacker to guess your password by brute force.  That said, making the password slightly longer generally does that more effectively than sprinkling "weird" characters into your password (obligatory xkcd link), so you should only use non-English characters in your password if you can type and remember them easily, e.g. because you speak a language that uses those characters.

Still, there are some reasons why you might sometimes not want to use non-ASCII characters in your password:

They might not be easy to type, if you ever need to log in from a shared / borrowed computer with a different keyboard, or if your own computer's keyboard layout gets switched for some reason.

(Actually, the same goes for ASCII punctuation too, since a lot of keyboard layouts like to switch those keys around.  But at least you usually can type them on any keyboard.)
The system processing the password might not accept them.  People have funny ideas about what counts as a valid password, and especially some older systems (and especially if they were developed in the US) might simply refuse to accept anything but printable US-ASCII characters in passwords.  They might even have sort-of-valid reasons for doing that, e.g. if the passwords are internally passed between old legacy systems that use different character encodings, or that break on non-ASCII data in some way (see below).
Even on the client side, some of those old charset issues might still rear their head.  For example, if the password is typed into an HTML form on a web page, and if the page does not explicitly specify its character encoding, different browsers might auto-detect different encodings, causing the password (and any other text entered into the form) to be encoded differently.
For some writing systems, Unicode normalization could also cause problems.  Without going into details, there are several equivalent ways to represent many characters in Unicode.  If the password processing system does not explicitly run the password through a Unicode normalization algorithm before hashing it (and many do not), then it's possible that typing the same character on different computers might result in a different sequence of Unicode code points, causing passwords using that character not to match.

If the back-end that handles the passwords was never designed or tested with anything but ASCII characters, it might also simply break when given input it doesn't expect.  For example:

Different parts might handle non-ASCII characters differently.  You might expect that all password processing in a given system would go through the same code, but in practice, there could well be multiple implementations password hashing (e.g. for different user interfaces to the same back end data), and they might not agree 100% on unexpected inputs.  This could e.g. mean that your password might work over the web, but not with a native client app, or vice versa.
The system might strip away non-ASCII characters, or even truncate the password at the first such character.  You'd think that would be a crazy thing to do for a password (and it is!), but the system might e.g. be running all input through some generic "input sanitization" function that simply strips away anything it doesn't recognize as "safe".  In most cases, that's not a terrible security measure to take (even if it would generally be safer to signal an error instead of silently discarding data); for passwords, it could be disastrous.
The system might internally use non-ASCII characters as delimiters, on the assumption that those characters will never appear in real data.  That might seem like a silly thing to do, but I've seen it done, including here on Stack Exchange.  At best, such as design would force the system not to accept such characters in the delimited data; at worst, using such characters could cause the data to be truncated or garbled.  Obviously, that could be really bad for a password.

(Of course, some systems may do this with ASCII delimiters, too, leading to silly restrictions like "password may not contain @ or %".)
The system might limit the password length.  A lot of old password hashing schemes (and even some relatively modern and otherwise seemingly decent ones, like bcrypt from 1999) will not accept passwords longer than some number of bytes, and may even silently truncate passwords longer than the limit.  This is a potential security problem in general, but it can be exacerbated by the use of a variable-length encoding like UTF-8, where non-ASCII characters take up two or more bytes per character.  Thus, for example, a system that limited passwords to 16 bytes of UTF-8 could handle a 16-character ASCII password, but only 8 characters of e.g. Greek or Cyrillic text.

The upshot of all this is that, in general, using only printable US-ASCII characters in a password is least likely to trigger software bugs or limitations.  Given that password handling bugs can often be difficult to deal with (since the only response you'll often get is "invalid password"), a lot of people may find it easiest and safest to stick to them.

If you do want to use a non-ASCII password (e.g. to make yourself less of an easy target for brute force password cracking, or just because it's easier for you to type and remember), you may want to test that the system really handles your password in a (reasonably) sane way.  I would suggest testing at least:

that you can log in with your password (using all available login methods, if the system offers several, and with all browsers or other clients you're likely to use);
that all features linked to your password (like, say, encrypted storage) really work correctly; and
that you cannot log in with simple variants of your password, e.g. with some non-ASCII characters changed or with extra characters appended to the end.

In any case, there's an argument to be made that, at least in 95% of all cases, you should not be choosing your own passwords anyway.  Rather, you should be using a secure password manager, and letting it generate random passwords for you.  Such randomly generated passwords will typically be long strings of random printable ASCII characters, to maximize entropy while minimizing potential compatibility issues, but it really doesn't matter much since you don't need to type or memorize them yourself.

Of course, you do still need to choose a password for your password manager.  But hopefully your password manager, at least, is well written and will handle non-ASCII passwords correctly.


Published data sets for IDS/IPS evaluation I am looking for data sets published by researchers or freelancers which can be used for the purpose of IDS/IPS testing and evaluations. The data sets may be for portscans, DoS attacks, Remote to Local attacks, User to root attacks, or all of them. The bigger, the better.

Something on the lines of DARPA Intrusion Detection Evaluation Data set will exactly suit my needs. (http://www.ll.mit.edu/mission/communications/ist/corpora/ideval/data/index.html)

There is some repositories of pcap traces. Some have traces of malware, port scanning, etc.. You can then replay these traces with tcpreplay.

http://www.pcapr.net/browse?q=malware
https://www.evilfingers.com/repository/pcaps.php
http://www.caida.org/data/passive/ddos-20070804_dataset.xml < DDOS.


Hidden OS: Decoy OS ≠ Hidden OS? I wanted to use two different OS then two OS equal in the distinct functions:

Hidden OS: Linux

Decoy OS: Windows

Has how? because what I have read until today were processes done with even OS, I do not know why this way, but it would not be useful for me, since I need two different OS for different purposes, and I don't want to choose to have two equal OS for different functions.

Well, I have another doubt also

If I wanted that my Hidden OS were a live USB, as tails OS, has how?

If so, would the same way?

Two passwords on the boot screen, one would be for the Decoy OS (Windows) if case I were forced to enter the password, so dodging the hidden, and the other pass for Hidden OS (tails). Haha, it would great if this is possible, and I hope so! :D

or would of other way?

of course, all this to be done through truecrypt ;)

Thank you!

I don't know of any bootloader that will allow you to change the selected OS based on password entered alone, I would say you would need to customise a bootloader to achieve this.

This link may be of interest to you also:
veracrypt

As may this previous Answer


Why are vulnerabilities and lack of security possible in computers? I have heard about computer vulnerabilities, virus, malware, etc.

Why are these threats possible?
Why doesn't the computer just do the things it is supposed to?
Why do some people write malware, instead of programs with a constructive purpose beyond doing damage and violating the law?
Does computer insecurity exist because of the nature of computers?

The computer cannot guess what it is "supposed" to do. Instead, it does exactly what it is told to do -- that's what programming is about. As a corollary, computers have no initiative whatsoever, so if they are asked to do something stupid or nonsensical then they just do it.

A bug is what happens when the sequence of instruction written by the programmer makes the computer do something stupid when presented with a specific set of data -- that is, stupid with regards to what the programmer wanted the computer to do in his high abstract picture of the system. But the computer does not know what the programmer wants, and even if it knew, it does not have the power to "understand it". The computer just follows the instructions to the letter.

A security issue is a kind of bug which can be exploited to the advantage of a malevolent third party, who will trigger the situation where the bug occurs in order to benefit from the nonsensical behaviour of the computer.

So, to sum up, security issues occur in computers because bugs exist and because evil exists.

Existence of bugs is due to the fact that making bug-free software (or, for that matter, bug-free hardware) appears to be overwhelmingly hard. This is an active research area and it is not ready to deliver anything workable yet. As an anecdotal example, consider that the program used during Apollo 11 Moon landing had two bugs to the effect that Neil Armstrong had to go in american-manliness-overflow mode and use the manual control. If they could not make a bug-free program for the main computer of a 25-billion dollars program, how do you expect average programmers to do better ?

Also on the matter of formal verification, ponder this well-known quote from Donald Knuth: "Beware of bugs in the above code; I have only proved it correct, not tried it."

Existence of evil is also an open problem which has been researched for at least 4000 years and does not seem to be solved any time soon.


Is Certificate pinning different from CA pinning? I am trying to understand if pinning a certificate essentially means pinning the CA or if they are different how so ?

The generic processing of a certificate goes thus:

The client builds a certificate chain going from a trust anchor (a given certificate which is known a priori by the client) down to the server's certificate.
The client verifies that all signatures and other information are correct along the chain (each certificate has a subject and an issuer names: its issuer name must be equal to the subject name of the previous certificates; each certificate is signed and the signature must match the public key from the previous certificate; and so on).
The client checks that the expected server name (the one from the https:// URL) appears where it should in the server's certificate.

Certificate pinning is equivalent to turning the server's certificate into a trust anchor with limited scope: the client stores the server's certificate, and will used it as the trust anchor when validating the server's certificate again. In the description above, this means that when coming back to the server, the client will build a chain of length 1, containing only the server's certificate itself, which the client "trusts" in that context because it remembers it exactly.

Certificate pinning can be inclusive or exclusive; the former means that the client will accept the remembered server's certificate as a trust anchor in addition to its other, "normal" trust anchors (its "root certificates"), while the latter means that the client will use only the pinned certificate as trust anchor. The overall effect of exclusive certificate pinning is that the client will accept the server's certificate only if it is bit-to-bit equal to the one it remembers; no other certificate would be deemed acceptable.

Usually, when people talk about pinning, they mean exclusive pinning.

CA pinning is the same process higher in the chain. The client remembers a CA certificate (which may be an "intermediate" CA) as a trust anchor. There again, this can be inclusive or exclusive. Exclusive CA pinning means that the browser will validate the server's certificate against that CA as unique trust anchor; the certificate will be accepted only if a chain can be built coming from that specific CA, and none other.

The important points above are the following:

The client remembers a certificate from the server's certificate chain.
The client complains loudly if the actual server's certificate (upon an ulterior connection) does not match what was remembered (subject possibly to some heuristics to smooth out normal renewals).
This process is site-specific: this is the main departure of pinning from the usual "root CA store" model. What the client remembers and requires is for a specific target site. The remembered certificate (CA or not) is not general for all sites, but only for one.


Credentialed scans and the Burp Suite active Scanner I have been running scans on a few web applications that require a typical username and password to gain access to the website. I usually remain logged in through the browser my proxy is running through until the spidering of the website completes but I was curious if that was necessary once I start actively scanning hosts with Burp's scanner. It appears that the cookie, session id, etc. is already included in the request the scanner uses but is there any reason that I would need to ensure that the browser the proxy is running through is still logged into the site while the scanner is running? Taking this one step further, is it required that I remain logged in during spidering or does burp save the cookie after I first authenticate?

Burp has some relatively complex options available for session handling but in the basic case, the scanner will use sessions from burps "cookie jar", so as long as it knows about a valid session ID it'll use it.

If you invalidate your sessions while the scanner is running (for example by using logout functionality) then the scanner will likely stop working well on authenticated areas of the site (of course assuming here the logout actually invalidates the session on the server-side).

However if you just go to a different site without actively logging out then burp can continue to use the session tokens you had, for as long as they stay valid.

On some sites with aggressive timeouts, this can be a problem but you can use Burps Macro facilities to detect this kind of issue and re-login automatically.


What cellular network is used for automobile theft recovery? Can that be used for PCs and mobile devices? I'm interested in sending a remote wipe command to stolen IT devices, such as a cell phone, or wifi connected device.  However most remote wipe technologies require that the cellular service (or wifi) be connected in order to receive the command.

This requirement is self-defeating since the Wifi device will most definitely be out of range by the time the command is issued, and the cellular plan may changed before a impatient end user requires inbound calls to work on their replacement SIM card.

What set of technologies is used in automobile recovery?  (Is it still MobiTex?)
Is it possible to re-purpose the cellular technology used for Automobile theft tracking for PCs, cell phones, and BYOD devices?
What is the ideal set of technologies (low power draw, broad coverage) that would best enable this low bandwidth application?

MobiTex is still in use. As far as I recall (at least in EU) the frequencies are lower than "regular mobile frequencies" and hence the coverage is much better. Also, a lot of companies offer a combination of GPS and GSM/GPRS units to track and send/receive commands.

It's possible to re-use the cellular tech used for theft tracking for any device that can signal, e.g., take the iOS features, but obviously you'd either have to trust that devices signalling capabilities or add hardware to it.


What attacks are possible if you can scrape a list of users? Have there been any attacks (or can you think of a potential attack) that hinged on being able to figure out if a user exists in a system?

For example, in a web app there is a "Reset password" page where you enter an email address (which acts as the login name, which in combination with a password, grants you access). If you enter an email that is not in the system, it will tell you the user does not exist. If you enter an email that is in the system, it will give you an "email sent" message.

This seems to me to be a case where the less you can reveal, the better, but I also can't really think of a way in which it would introduce a vulnerability but it is inconvenient to not give the user more info.

There are a few ways this could be an issue:

Considering some of the fallout of the Ashley Madison hack, being able to confirm whether or not a person has an account on a given site can be of value. In the case of this hack (per the Wikipedia article):

  Following the hack, communities of internet vigilantes began combing through to find famous individuals, who they planned to publicly humiliate.

On a similar note, attacks like that on human rights activists, or even watering hole attacks can be better targeted if you are able to confirm (or not) that they have accounts.
Phishing (and in specific, spear/whale phishing) can be made more effective if you can identify a good source to spoof. In that sense, if you can confirm a user has an account on a given site, then you are able to increase your chance of successful compromise (tangentially related).

Possibly not what you had in mind, but I would also recommend you consider the methodology Brian Krebs uses in his investigations: he has been able to draw conclusive evidence about criminal hacking based on being able to tie people to online handles. This isn't an 'attack', but it can result in DoS'ing individuals for some time.

I suspect the case most relevant to your question is being able to confirm whether a site is worth compromising in order to get to its users.

Notably, I suspect that considering that particular vector might lead to some specific design considerations, such as having your 'Reset Password' return a message akin to "Request received", as opposed to "Email sent".


How do you explain to experts that a database server should not reside in the DMZ? Our security experts, database administrators, network team and infrastructure team are all saying it's OK to have the database server located in the DMZ along with the HTTP server and middle-ware server.

Their reason:

  If the database server is compromised (because of an insecure middle
  tier), at least the database server is outside the internal system. If it is
  inside our network, the hacker can then use the database server to access
  other systems.

What they are saying is:

  Let's not put the middle-ware server behind a second firewall and the database
  server behind a third firewall.
  Let's use just one firewall (the HTTP server's) in case a hacker wants
  to get our database's sensitive data, at least that's all they can get.

The second statement was actually said... verbatim.

Please note that this database server will hold sensitive information, including bank details.

Now, are these experts making any sense to you?
I'm a software developer, and I can't get their logic. It's like, "Put the jewelry box outside the house so that robbers won't bother getting in for the TV?"

It's like, "Put the jewelry box outside the house so that robbers won't bother getting in for the TV?"

Yes, it is exactly like that.

If you don't care about the value of the database, relatively speaking, then sure it makes sense to leave it outside - if the assumption is that the application is horridly insecure, but you need to put it up anyway for whatever reason, and don't want to secure it, then this is makes sense as a way to isolate this horrible insecure system from all the other internal systems.

On the other hand, there really is no excuse to expect to have SUCH an insecure application that allows complete database server takeover. Also there is no real reason to use "exposure" as an alternative to "isolation" - there are simple solutions to do that right too.

When it comes down to it, it sounds like this is one of 2 possible situations:

These so-called "experts" are really clueless.
There are other business requirements that are being traded off here.

I think your analogy works perfectly. If they then tell you the equivalent of "Actually, those jewelries are fake, oh and btw the TV is really a 60" 5K custom job with gold rims", then that might be a sensible tradeoff (still better to do it right, though).
Otherwise, it's likely that there is no way to explain it, since they are working from a lack of knowledge.


How can Telegram find my phone number on iOS 11 after uninstall? I wanted to sign in Telegram on my iPod Touch running iOS 11 with another account.

I deleted the app and install it again. On the sign up screen Telegram filled the phone number field with the number I was using 5 minutes before.
So I deleted the app again, cleared the advertising identifier, turned off the keychain, erased the pre filled text in iCloud, and restarted.
After I reinstalled the app the phone number was still there on sign up.

How can a new installed Telegram app find the phone number I was using?
I though that the latest iOS privacy features were preventing an app to track a user after reinstalling it.

From my understanding iOS 11 doesn't delete the keychain keys for an app when you delete the app, I'm talking about the keychain on the device so cloud settings won't affect this. No other apps can access another app's keychain so you don't need to worry about it from a security point of view but it's entirely possible the app is using the keychain store to persist the phone number information.


Using TPM persisted RSA key in Windows and Linux Our solution includes a Windows tool that creates/opens a persisted RSA key stored in the TPM and encrypts/decrypt data using it. This works flawlessly.
Now we need to decrypt that data but from a Linux OS on that same machine. Can it be done?
The windows code uses NCrypt API (error handling etc removed):
// Open TPM storage provider.
NCryptOpenStorageProvider(
    &prov,
    MS_PLATFORM_CRYPTO_PROVIDER, //Identifies the TPM key storage provider that is provided by Microsoft.
    0);

// Create persisted key
NCryptCreatePersistedKey(
    prov,
    &key,
    NCRYPT_RSA_ALGORITHM,
    "MyKeyName",
    0,
    0);

// Finalize so can be used
NCryptFinalizeKey(key, 0);
// Encrypt
NCryptEncrypt(
    key,
    (PBYTE)data,
    (DWORD)size,
    NULL,
    encryptedBuffer,
    encryptedBufferSize,
    &encryptedBufferSize,
    NCRYPT_PAD_PKCS1_FLAG);

What I'm going for is the Linux equivalent of
NCryptOpenKey(..., "MyKeyName", ...);

NCryptDecrypt(...);

But couldn't find it.
Thanks.

Interesting question.
I don't have a direct answer for you or a piece of code that translates yours into Linux land, but I am convinced TPM chips are usable as PKCS11 providers on Linux today. Please see the resources below

TPM2 and Linux
Securing key handling using TPM
TPM enabling the Crypto Ecosystem for enhanced Security
TPM2 PK11 (practical example under ark)

Please report back your experience, it would be interesting to find out how you got on.


What are the differences between ssh generated keys(ssh-keygen) and OpenSSL keys (PEM)and what is more secure for ssh remote login? I have learned there are 2 methods to make SSH remote login easier and secure , those are;

ssh generated keys (using ssh-keygen)OpenSSH Keys
PEM (.pem) keys usually generated with OpenSSL (Amazon Web Services uses this method) OpenSSL

my question is that what are the differences of these 2 methods which one is more secure and why is it more secure ?

The file format is different but they both encode the same kind of keys. Moreover, they are both generated with the same code: openssl (the command-line tool) is a wrapper around OpenSSL (the library), and OpenSSH actually uses OpenSSL (the library) for its cryptographic operations, including key pair generation. So there is no direct security difference.

We could argue a bit about password-based encryption of the private keys, but there is nothing really significant here.


Why should I trust a JSON Web Token (JWT)? In the SAML and Kerberos authentication models, there is an explicit understanding of what authority has authenticated the user and issued the credential to be trusted by downstream systems.  For purposes of identity propagation, the rights of the downstream system to impersonate the user can be tightly controlled within the solution architecture and the associated identity domains.

As far as I can tell, the completeness of the SAML and Kerberos models is not part of the JWT approach.  JWT appears to be a mechanism that provides functionality quite similar to Kerberos, but without the supporting functionality of a defined KDE.

Am I missing something?  Is JWT based on a "web of trust" or is each JWT implementation responsible for defining its own trustable authentication mechanism and so on?

So, a JWT is just a token. It's not a protocol. As such you really can't compare the SAML protocol to a JWT as that would be like comparing apples to ducks.

A JWT is just a bunch of identifying information signed by a cryptographic key. What you actually put in it is up to the protocol. There are some formal requirements that distinguish a JWT from a JWS object like issuer and audience information, but that information is still arbitrary. Comparatively SAML tokens and Kerberos tickets do have a bit more structure to them, but that's not to say you can't add the same information to a JWT.

Protocols on the other hand are a bit trickier to compare.

The two protocols people generally think about are OAuth2 and OpenID Connect. Both can and do use JWTs as their token. OAuth2 often uses JWTs as an authorization mechanism -- the presence of the JWT and the claims in the JWT determine what sort of permissions the caller has against a protected resource. It has nothing to do with identifying the user. Conversely a protocol like WS-Federation uses SAML tokens by default to provide identifying information about the user, but can use JWTs as drop in replacements (so long as all parties understand the format) because you can put the same information into the JWT body.


How to encrypt data on the server? I have some data on the server (running Linux) which needs to be encrypted (company policy). This data is being served by an application running on this machine. Now I consider a few possibilities:

1) Encrypt only the partition on which the data resides (by the OS).
2) Encrypt only the data in question (some 3rd party software) but not the whole partition.
3) Encrypt everything.

Which option would you recommend? The thing I am most concerned about is performance as this data is heavily utilized. Currently we don't have a possibility of using encrypted SAN disks. The above seem to be the only options. Could you please tell me which option is the best and what software/tools would you recommend to implement it?

There are a number of defenses you can use to help prevent and recover from theft.

The first thing you should look into is full-disk encryption, e.g. LUKS, TrueCrypt, or PGP. This will prevent an attacker from reading any data on the disk, even if they steal the hardware. You will need to enter the password at boot, though, so for unattended remote hardware this might be problematic unless you have access to lights-out management (e.g. HP iLO or Dell DRAC).

On top of this, you should ensure several other mechanisms are in place:

Strong physical security in your data center (e.g. locks, biometrics, CCTV, alarms)
Security procedures should be put in place at the data center. All people entering should be made to sign in, and all hardware access / changes should be logged and signed for.
Good server racks come with appropriate fixtures for padlocking servers in place. If available, this feature should be used. Select a strong padlock that is resistant to bolt croppers and shivs.
BIOS administrative password set, to prevent the boot order being changed.
BIOS boot password set, if possible (may require physical attendance at boot)
Application credentials can be stored in a dedicated HSM to help prevent recovery of data in the event of theft.
Epoxy resin can be used to disable physical ports, to prevent unauthorised devices from being plugged into the system.
Asset IDs should be properly set in the BIOS or server management console, and should be logged in an assets registry.
UV ink should be used to tag all devices. You can buy UV security pens very cheaply, and they're very useful for property identification in the case of theft. It is often worth marking individual hard disks as well as the server chassis.
Tamper-evident mechanisms, e.g. security tape, can be used to ensure that the hardware has not been tampered with. A quick and easy way to use it is to tape up the server and sign the tape with a marker pen. If the server is opened later, the seal will be broken. New tape applied over the top will not carry the same signature.


Which is the most vulnerable to MITM attacks, SSL or SSH? Which is the most vulnerable to MITM attacks, SSL or SSH?

Here's the scenario, you have 20 minutes to set up a web proxy like this:

Laptop -> Chrome Browser -> Web Proxy -> Internet

You must secure the connection between the Laptop and Web Proxy Server, nothing after the proxy matters, it's just the laptop to proxy connection we care about for now.

You can use SSL or you can tunnel the web traffic over SSH, all we care about is security, not performance.  Which would you use, SSL or SSH and why?

With SSH, things are done like this:

on the laptop, run ssh -N -D 5000 proxy-machine (where proxy-machine is the DNS name of the "Web Proxy" machine);
configure the browser to use the SOCKS protocol on localhost and port 5000.

This is convenient, and activated in much less than 20 minutes. It has, however, the following consequences:

The laptop user must run the ssh command and keep it running as long as he wishes to browse the Internet through the proxy.
The ssh command must be installed on the laptop (it is standard issue with MacOS X, Linux and all the Unix-like systems, but not with Windows).
The Web Proxy machine must run an SSH server.
The laptop user must have an account on the Web Proxy machine (it is possible to restrict that account to the setting up of tunnels like the one above, but it is not easy to configure).

With SSL, you would have to install some proxy software on the Web Proxy (e.g. squid) and configure it with an X.509 certificate, so that clients (the laptop) use https://proxy-machine:9000/ as proxy URL (the port number can be changed at will, I used 9000 as an example). There is no software to install on the laptop; the browser just has to be configured to use the right URL as an HTTP-level proxy. Be wary of proxy autoconfiguration scripts, they could be ways for the attacker to force another proxy configuration; you'd better configure the proxy manually.

SSL and SSH use distinct protections against Man-in-the-Middle attacks. The SSH client records the public key of the target machine (in the $HOME/.ssh/known_hosts file on Unix-like systems) so that it may check that the server public key is the right one; only the first connection ever is vulnerable. SSH public keys have fingerprints (i.e. hash values) which can be used to check that a key is correct (the idea being that you can phone the sysadmin, and he will spell out the fingerprint; this is tedious but needs to be done only once per SSH server). Until the laptop or the proxy is compromised, or the cryptographic algorithms get thoroughly demolished by irate cryptanalysts, the SSH way is secure.

SSL relies on X.509 certificates. The security comes from the set of trust anchors (aka "root certificates") already embedded in the browser (or the operating system). The certification authorities are supposed to issue certificates only to duly authenticated entities, and the digital signatures are the cryptographic tools by which the browser may verify that certificate contents have not been tampered with, and only accepted certification authorities have been involved. To mount a MitM, an attacker would have to bribe a CA into issuing a fake certificate, with the name proxy-machine, but with a public key owned by the attacker.

The X.509 security relies on a lot more assumptions than the SSH security, which is handled locally and where what happens is pretty simple. But the SSH scenario requires the laptop user to be a bit more aware of what is happening. For me, I would use SSH (indeed, that's what I do); for an organization with many users, I would follow the SSL path (but the "20 minutes" requirement would be a joke).


Why Wordpress doesn't filter post_title? Today, when I did some tests and found out that Wordpress doesn't filter the post_title.

Respectively, I make posts with the titles:

<?php while ( have_posts() ) : the_post(); echo 'Post Title'; endwhile;?>
Post Title

I. With the first post, Wordpress puts entire title in html comment tag:
. Then no title shows up for this post.

II. The second, Wordpress return a title linked to http://stackexchange.com/.

III. The worst thing is the third one. A pop-up window with "Post Title" message appears three times. It's weird! What is Wordpress executing?

I made this test with Wordpress 4.2.2 on Twentyfiteen theme. I don't know much about security.

Does this bug(s) can be exploited and How do I filter it?

Some general information:
While it might initially look like a bug this is not considered one.

There are certain roles in a WordPress site (like admins and editors) that have the ability to post unfiltered html to the website. This includes the post title which is the one you used here. This is not considered a bug since one can assume that the person that has admin privileges for the specific site can add or remove any content he wants anyway.
See this link for further official information:
http://codex.wordpress.org/FAQ_Security#Why_are_some_users_allowed_to_post_unfiltered_HTML.3F

You can think of it in a way that putting your above mentioned script block on your personal website would not be considered a bug either.

To answer your questions:
Wordpress will put the unfiltered html in the spot where the page title would be included. This will be a link if you chose your second input, a JavaScript script block (that will then be executed by your browser) if you chose the third one or basically any input you give it.

WordPress will however not interpret php code if it is posted there. It will only include the input as a string and modify the tags to resemble html comments.

However if all of this seems strange to you and you don't want administrators and editors to be able to post unfiltered html to your site you might want to add:

  define( 'DISALLOW_UNFILTERED_HTML', true );

to your wp-config.php file (as described in the above mentioned link).


Cross sign two self signed root CA I have two self signed root CA that was used for separate kubernetes clusters (say cluster A and B). Both CA is used to sign application certs in their respective cluster.

However, one of the application inside cluster A needs to access another application in cluster B which require a client cert authentication. The application in cluster B can be configured to trust some CA cert, which by default is trusting root CA of cluster B.

My initial Idea is to have a cross signed intermediate CA which will be trusted by the application inside cluster B. This intermediate CA will be cross signed using root CA from cluster A and root CA from cluster B. Is there a way for me to do it ? Will the application trust the cert from cluster A which is signed solely by root CA of cluster A?

Yes, cross signing is possible.

What you need to do is let A sign a CA certificate which

uses the same key as B
uses the same subject as B

(and vice versa). If those intermediate certificates are made available, then there are two possible chains for each end entity certificate signed by either A or B which end in either of your roots.


Can the Police trace an internal user which is behind a shared IP? Can the Police or any other lawful body obtain information about a criminal from the ISP knowing such things as the shared IP (the NAT, I believe?), timestamps, visited websites etc.?

Since the ISP knows the owner (the one who pays the bills) and street address of the shared IP address police will likely start there. They might simply confiscate the systems in this home and question the inhabitants for more information, i.e. do it the analogue way and not try to somehow trace some internal computer back through the internet.


How to best educate users on telltale signs of malware infections? My company is in the process of training and testing all employees on our security policies and practices. As a member of the team doing this training and testing, I had a thought that it may be beneficial to invent a set of drills. These drills would test against different critical security controls as well as the execution of the response plans. I know a number of companies do tests like these for phishing, which we will also do.

One thing that I'd like to test is a suspected malware infection. My thought process for this is to have someone with remote administrator access to a given employees machine could trigger an event which emulated a malware infection. More importantly, it would be an infection which bypassed our anti-virus.

Obviously, there are a number of behaviors which a malware may exhibit, with the "ideal" (for the malware) being to exhibit no behaviors. That said, is there a set of malware characteristic behaviors that could be replicated in a safe and reversible manner by an administrator or tool we have installed on their system? A list of my current thoughts:

Browser hijack - Redirect the user's browser to a malicious intranet page
Edit the hosts file - Redirect common IPs/DNS entries to a malicious intranet page
High CPU Use - Emulate a botnet or bitcoin-mining malware by creating a spurious process which performs harmless but excessive calculations
High Disk Use - Emulate a current ransomware attack by creating a spurious process which performs harmless but excessive disk reads/writes
Ransomware popup - Create a popup image taken from one of the popular ransomwares and simply show the ransom page
Unauthorized access - Have an administrator remote in and leave open a page signed in to something like an AdSense account, signed in to the "attacker's" account (I've seen this happen before)

Are there any that I'm missing? Any that should be removed?

Whatever battery of tests we create may not be exhaustive, but the goal is to simply test that employees are being attentive to these kinds of breaches and report them when detected. Hopefully this will have the side benefit of having them be more sensitive to these kind of attacks at home as well.

I would question the value of anti-malware software which cannot detect unusual behavior and why other layers of defense are not detecting attacks. For the list you proposed, there are legitimate reasons for most of those things to occur, so I would not expect an end user to think they should report this as malware. You could find or write a tool that detects and reports on these scenarios (e.g., HIPS, IDS/IPS, stateful firewall, etc.).

Perhaps the more reasonable scenario is the user contacts IT for weird behavior and IT does an investigations, malware scan, etc.

End users should be your last line of defense (The military does not rely on school teachers instead of intelligence agencies). Reliance on end users usually indicates insufficient technical controls. Most organizations do not deploy anything beyond spam filters for email and emails are designed to be something end users interact with on a daily basis. I would be surprised if end users event know how to monitor utilization or what a hosts file even does or where it is located.

An important thing to consider with the rise of phishing simulation and testing it the market/vendor effect. Phishing simulation is pretty much the same as sending marketing emails with tracking links, its not super complicated software to write and the sales pitch is relatively easy.

At a higher level, a drill is a good thing to test, but you should focus on your response from the IT team, not end users as a KPI. For example, how quickly can IT identify and quarantine a machine are they asking the right questions to determine if there is malware and investigation is necessary or are they just trying to close out ticket as quickly as possible?

If you want to test your malware response from end-user reporting and IT follow-up you can use an EICAR test file.


SSL traffic manipulation through ettercap MitM and iptables I am trying to understand the relation between some tools and concepts used for MitM on a wifi network and how https transaction (over this wifi network) between an android app and the respective server can be intercepted and modified . I am new to this domain, so please bear with me.

So I want to CAPTURE and MANIPULATE all the HTTPS traffic between an android app and the server it is communicating with. The user using the app is on a WPA/WPA2 PSK network. I have already captured the intitial WPA handshake and have been able to successfully brute-force the PSK through the handshake and now I am a part of the same network as the user using the target app.

Now to be able to capture the traffic I need to gain an MitM position. There are a bunch of ways of doing this. There are a couple I know, including Cain APR and ettercap.

I choose to use ettercap to ARP poison the victim. Now since the mobile device communicates over SSL and I want to intercept this SSL communication, I make the required changes to etter.conf and turn on ip forwarding on my system to do ettercap certificate impersonation, where ettercap actually generates imposter server and CA certificates on the fly.

The above technique would still present the victim with a certificate error warning and if the user accepts that the fake cert is added as a trusted root CA on the victim's device.
I could have used SSL Strip here but again, if the user connects to the server directly over https (without a redirect), SSL Strip may not be the best solution.

Now although I can sniff SSL traffic now, but it would be relatively tougher to manipulate this SSL traffic using ettercap. So instead I try to use iptables to redirect traffic to an alternate port number on a second port on the local system where I have another software running that would allow me to manipulate the data in the redirected traffic.

Now let's say the software I am running on this port is BURP Suite, which is something I would want to use to fiddle around with the data.

Now the thing I am getting confused with is:

  BURP has it's own Portswigger certificate. However, using ettercap I have already  done a certificate impersonation earlier. So now, when I forward all of this traffic (using IP Tables and setting up BURP to use Transparent Proxy) to BURP, will I need to get the Portswigger certificate also trusted on the client's device ? Please explain either yes or no.

As a real world attacker the above would probably be one of the methods I might just use to launch an attack. Is the above understanding correct ?
As a pen tester another way of achieving this that I can think of is if I install an SSH server on the test device and also install Shark(in the case of Android)/some other tcp dump like tool and then monitor/analyze (using Wireshark maybe)all the traffic remotely through an SSH client on my local system ? Will this let me do the intended job ?
What could be some other ways of doing this ?

The best solution is when ettercap does not MiTM the SSL connection, just forwards it to Burp, and Burp can be set up as a transparent SSL MiTM proxy. In this case, the client will see Burp's server certificate, which has to be trusted by the client. As you can see on the following, only 2 SSL connection is set up.

           SSL1            SSL2
Client <--Ettercap--> Burp <--> SSL Website

Although both ettercap and Burp can be set up as SSL MiTM, it makes things only more complicated. In this case, the client will see ettercap server certificate only, so you don't have to add the Burp's certificate to the store. In this case we will have 3 different SSL connections, but it does not have any advantage compared to the previous one.

       SSL1          SSL2      SSL3
Client <--> Ettercap <--> Burp <--> SSL Website

To answer your questions:
Yes, as a real world attacker the above would probably be one of the methods you might just use to launch an attack.

SSH-ing into the Android device and using Shark won't be enough. You won't be able to manipulate the traffic. You will be only able to decrypt the traffic if you have the TLS/SSL server keys (which is usally not the case) and perfect forward secrecy is not used.


If I leave SPF not set on my domain, is that a factor for email servers to mark emails from this domain as spam? I wonder if the lack of an SPF DNS record is a factor in the decision to mark a message as spam.
I understand that an SPF fail is definitively such a factor, i.e. when SPF is configured, but a message has "MAIL FROM" / "Return-Path" domain not on the list in the SPF record.
But is the consequence of not setting SPF only letting spammers roam free? Or does it also "de-value" legitimate emails from my domain in spam algorithms, because there's no way to check?
In other words, assuming spammers don't currently spoof emails from my domain much, may adding SPF improve deliverability of legitimate messages?

An absence of SPF isn't supposed to hurt you, but some anti-spam systems are set up to be rather aggressive and I'd worry about your luck given a system using a best-guess record (v=spf1 a/24 mx/24 ptr ?all) and then penalyzing a netural result (I don't know how common that is).
Side note: PTR in SPF is extremely ill advised (it lets any network owner forge mail as you). I also highly advise against over-permissive records like v=spf1 +all, as that's a spam indicator.
My recommendation is to at least give yourself v=spf1 a mx ?all if you self-host. Add your mail provider if you have one, e.g. v=spf1 a mx include:_spf.google.com ?all if you use gmail (you should be fine with include:gmail.com, but run it through a checker like this one). Also consider using DMARC reporting to figure out what you've missed.
If all of your mail is DKIM-signed by your domain and therefore passes DMARC, you should add an SPF record like v=spf1 ?all to make it clear that nothing passes SPF and that best-guess records should not be applied.


Why companies do not simply use hackers' tools to find their own vulnerabilities prior to the release of their software? It may be a silly question, but hackers do use publicly-available tools to find vulnerabilities. So why don't companies, before releasing their products (Windows, Adobe etc...), use the same tools to find those vulnerabilities and fix them?

I don't understand. Am I missing something?

They are doing it, or at least they're expected to do so, as part of their Software Development Life Cycle (SDLC).

In terms of vulnerability management, a best practice would be to first perform a source-code review (static/dynamic), and to scan their product using a vulnerability scanner. Note that there are also other steps to enforce a secure SDLC, such as threat modeling, secure coding guidelines, etc. that should be performed as well.

In real life, this is 90% of the time seen as a "useless" activity, because it requires resources but doesn't generate revenue or add new functionality to the application.


Secure Image Upload, or Bypassing PHP mime-type Check When securing image uploads there are basically three approaches I know of (of course, ideally, all three are used):

check file extension
store uploaded files in non-executable directory outside the webroot
check content/mime type of the file

For the third point, there are various PHP functions which are suggested, most of which can be bypassed by encoding the code in IDAT chunks. Here are the results I get:

<?php $image = 'imageshell.png';

echo exif_imagetype($image);
// -> 3 (IMAGETYPE_PNG)

echo "
" . getimagesize($image)[2];
// -> 3 (IMAGETYPE_PNG)

echo "
" . mime_content_type($image);
// -> image/png

echo "
" . finfo_file(finfo_open(FILEINFO_MIME_TYPE), $image);
// -> image/png

echo "
" . finfo_file(finfo_open(FILEINFO_MIME_TYPE, "/usr/share/misc/magic"), $image);
// -> application/octet-stream

I basically have these questions now:

Why is the result different if I pass a magic file (shouldn't it still accept the file as an image file, as that is what it actually is?), what exactly is a magic file, and what does PHPs inbuilt magic file look like?
Can I check beforehand if the system has a magic file that will result in correctly identifying a non-image or an image which contains PHP code?
If I can't, is there a better approach to check if an image file contains PHP code?
Is it possibly to bypass the last check - the one resulting in application/octet-stream - as well?

Why is the result different if I pass a magic file (shouldn't it still accept the file as an image file, as that is what it actually is?), what exactly is a magic file, and what does PHPs inbuilt magic file look like?

A magic file is the description of some heuristics to determine the file type. Different results can be caused by different magic files but also different implementations of the heuristic engine.

  Can I check beforehand if the system has a magic file that will result in correctly identifying a non-image or an image which contains PHP code?

The various file magic functions are designed to detect the file type only by looking at a few bytes at the beginning. They are not designed to find out if there is PHP code hidden inside the file. It should be possible to create a polyglot document which is both valid PHP and a valid image.

Which means checking the content/mime is not a sufficient validation.

  If I can't, is there a better approach to check if an image file contains PHP code?

It's better not to just check but instead to make sure. This can be done by converting the image into a different format and stripping all meta information.

  store uploaded files in non-executable directory outside the webroot

That's actually the best way. But make also sure that you cannot be tricked to include the file in another PHP script, i.e. Local File Inclusion.


How to know if an RFI/LFI attack was successful? Let's say that an attacker wants to search websites for RFI/LFI vulnerability with a script, he's fuzzing the URL with a list of remote/local files. And he prints the headers that return from the request. How can the attacker know when the RFI/LFI was successful?
Is the content-length header can tell us something?

If RFI/LFI does not work on one (valid) file, does that mean there is no chance of this attack at all? Or can I keep trying other files?

Is the content-length header can tell us something ?

It may depend on the particular server and application. In many cases, the HTTP response will contain the contents of the requested file itself, or the output of executing it. So usually, you'd just confirm that a file was returned.
If the content length for an invalid file is 0, and a valid file is > 0, then that could work. I don't know if it would be that cut and dry, however, but maybe you can identify a baseline value vs a valid file hit. But maybe instead the particular application instead returns an HTTP 500 code if the file is invalid. It's probably good to try files that you know exist, so you can calibrate the expected response based on how the server responds.

If RFI/LFI does not work on one (valid) file, does that mean there is no chance of this attack at all?

Depends how you define "valid". If the file exists but you do not have permission to read it, then you will probably get a negative response. There also may be path filtering or a forced file extension; in these cases you may only be able to view certain files.


Can it be dangerous to use not popular(unknown) dns servers? There is a service called tunlr, which let's you browse the web with no restrictions(Pandora, Hulu etc.). You just have to use their dns server.

But now I'm concerned whether the owners of the dns server could track usernames and passwords? Or are there even some other threats?

A major concern would be that if you requested a legitimate domain, such as Google.com, they could direct you to a non-Google owned IP address. This would not be the site you were hoping to visit and there are major security concerns there. For example, the third-party website could be used to deliver malware. It might not be noticeable to you either. A common payload attack would deliver the legitimate website and embed a malicious iframe on the site. It's generally safest to use a known and trusted DNS provider.

See DNS Hijacking for more information:
http://resources.infosecinstitute.com/stop-dns-hijacking/