How do attackers find the IP addresses of recently deployed servers? About two months ago, I deployed an Ubuntu server with as main purpose serving a web app. However, I'm still developing the app and only gave the server IP to my coworker and some friends for testing.

Yesterday I checked the fail2ban logs and noticed many SSH bruteforce attempts from China, France etc. that dated to before I gave out the IP. I also checked my server access logs and noticed some malicious attempts on URLs from the same IPs, trying to bruteforce SSH. One example of a request they made is myip/otherip/file.php. I'm not sure how to interpret this. I traced back the IP of that server and it's on the same hosting company I'm on.

Question: How did they find out about the IP of the server before I even served the app from it or gave it out?

My guess: I'm guessing it is some bot that keeps trying on different IPs of some pattern that leads to servers of the same hosting company. Is that a correct assumption, or are there other possibilities?

Your guess is likely correct.

The big server hosters have continuous IP ranges from which they assign IPs to their customers. Low budget hosters are frequently used by amateurs who don't know what they are doing, so it's likely that they use easy to guess passwords or set up insecure web applications. This makes these IP ranges valuable targets for black-hats.

When you notice such attacks from within the hosters network, you should report them to the hoster, because this is very likely a breach of the terms of use... or a server from another customers where the black-hats were already successful.


Is the ISO/IEC 27001 standard incompatible with free/open source software? The ISO/IEC 27000-series of standards lay out how to create and manage an information security management system (ISMS). The ISO/IEC 27001 document provides the main body of the standard and is augmented by a number of sector-specific guideline documents.

The 27001 document includes a lengthy Annex listing a full list of 114 controls, grouped into 14 clauses and 35 categories, against with an ISMS can be audited.

Control A.9.4.5, ‘Access control to program source code’ states the following:

  Access to program source code shall be restricted.

Does this mean that ISO 27001 is incompatible with free/open source software, for which the source code is not and can not be restricted?

Is there any way of waiving this, or would any such software produced by an organisation just have to be excluded from the scope of any 27001 certification?

"Access to program source code shall be restricted." does not mean that nobody should be able to access the source code but that it is defined who can access and change the code. The main point is not to have the source code secret but to prevent unauthorized and unaudited changes to the source code.

And this is true for using open source too: one should not simply import and use some code or patches from somewhere without somehow making sure that the code is actually having the expected behavior and only this, i.e.that it does not contain any backdoors and no critical bugs etc. This "somehow making sure" does not mean to audit everything yourself but might also mean to trust upstream distributions and maintainers to do the right thing. How much to trust upstream or how much to review code yourself of course depends on both who is the upstream and how critical the code is which uses third party code.

But blindly using npm, cpan, pip etc to install modules can be dangerous and is against the spirit of using and writing secure code, see Small World with High Risks:
A Study of Security Threats in the npm Ecosystem or Malicious Modules — what you need to know when installing npm packages.


GSM A5/1 encryption: Key management I'm currently studying the A5/1 algorithm used for GSM encryption. I understood how thanks to the symmetric private Key and a public counter frame one can encrypt the communication between A and B.

However, what I don't really understand is how the symmetric private key K is managed ? If A wants to communicate with B. A and B have to share the same secret key K. Now, if A wants to communicate with C, A and C will have to share the same secret key. How does this key distribution is handled ? Does the phone company distribute them before the call ?

GSM uses three different security algorithms - A3, A5, and A8.
The A3 algorithm is used to authenticate the mobile device,
the A5 algorithm to encrypt the data transmitted,
and the A8 algorithm is used to generate the session key.

Hence, I believe you are interested in the A8 algorithm which deviates the session keys through a  challenge and response handshake. However, I the session keys are shared between the user and his base station only and not between two communicating parties. The base station will decrypt the data and transfer it (most probably in plain text) to the other party's base station which then encrypts the data with the key shared with the other party of the conversation.


How to identify the HTTP methods supported by a web server? How can I identify the different HTTP methods supported by a web server, like OPTIONS, TRACE, etc.?

I have tried the nc command on Linux. But it doesn't work. It doesn't show me the HTTP methods supported, some other HTTP headers are returned along with the requested HTML page. Is there another solution?

Per RFC2616, the OPTIONS method should return the supported methods. Keyword is should since this isn't always the case. As the prior posts have already pointed out each method needs to be tested separately to be sure.


Data classification and data leak prevention We have several levels of data classification such as secret, confidential, etc for documents. To prevent leakage of such sensitive information to the outside, I am considering using a DLP solution.  However, I don't really understand the mechanics behind how these solutions do tagging of the classification. Do they do something to the metadata of the classified documents? Any explanation on how "tagging" works would be much appreciated.

I don't have much experience with other vendors' solutions, but the way Fortinet does it is that it:

Inspects the data being sent through the firewall, and looks for a match in plaintext or file type based on rules set up by the firewall admin (for instance, any text string that matches a social security number format, or any file that's a .jpg)
Looks for a watermark. You run a file such as an .gif or .pdf through the vendor's watermarking software, and it will embed a steganographic watermark in the file that the firewall will recognize.
Looks for a "DLP Fingerprint" match. You run a sensitive file through the vendor's fingerprinting software, and it generates a checksum that the firewall can use to identify files that should not be leaving your network.

The firewall either has access to the sensitive document repository, where it automatically generates DLP fingerprints for the files in it based on rules set up by the admin, or the admin manually creates DLP Fingerprints using the firewall or software provided by the vendor.

These signatures have fine grained actions associated with them - for instance, your CFO may be permitted to upload a quarterly report to an accounting firm's server, but the janitor is not. The firewall works in conjunction with your AAA (authentication) server to determine who can do what with which type of file that triggers a DLP sensor.


How is this iphone VPN app working? I am using an iphone app called tunnelbear. I was wondering if my ISP gets to see my network traffic (aka the URLs I am visiting) when I am using the VPN.

I did a small experiment using Paros following this tutorial. This is what I see from Paros normally (all URLs my iphone is accessing).

When I use the VPN, I don't see any website that I am accessing on my iphone.

Give this, I have two questions:

My understanding was that when we use a VPN, the traffic gets encrypted and goes to the VPN server. Therefore, shouldn't I see the address for the VPN server each time I try to access an URL?
Given Paros doesn't see the URLs I am visiting, can my ISP see them?

Paros is an HTTP/HTTPS proxy, so it only handles those specific protocols.  Most VPNs use IPSec or OpenVPN as their application protocol, so Paros would not see them.

Your ISP will not see the URLs you visit, only encrypted traffic to the VPN provider.  Your ISP can trivially identify that you are talking to a VPN provider.  Your VPN provider can (if they choose to) see all of the web traffic you send.  (Full URLs for HTTP, only hostnames for HTTPS.)
 Also note that an attacker who can see both traffic into the VPN endpoint and out of it can trivially identify the VPN user who is originating traffic to a given site.


Security of GPG encryption with AES and MD5 if MD5 is broken I have a file encrypted with gpg, using AES256 and MD5. Suppose that the MD5 hash function is broken, but not the AES cipher. Does that make it easy to crack decrypt the file?

Depending upon to what extent MD5 is "broken", a break of MD5 might enable chosen-ciphertext attacks.  However, as far as I know, it won't enable purely passive eavesdropping.

That said, the likelihood of a catastrophic break of MD5 (bad enough to compromise the secrecy of your gpg-encrypted data) is probably much lower than other risks your system faces.  I think it's unlikely that this is the weakest link in your system, or that this is anywhere near the biggest risk in your system.  This risk is likely nearly negligible, compared to other kinds of risks that tend to be present in most information systems.


What cryptographic algorithms are not considered secure? What cryptographic algorithms are not considered secure, but yet are still widely used and available in standard libraries? If applicable, mention a secure alternative.

These are the most common:

MD5 - Use SHA512
SHA1 - Use SHA512 (Note this is not really insecure, but its showing its age, and will be fragiler in the next couple years....)
DES / 3DES - Use AES


Is this slowloris attack or not? IP is hidden in apache log for privacy, except last octet.
/billing is our application start page. But it doesn't make sense that it sends POST requests, and get 500 response.

Or maybe this is legitimate old IE 7 browser who can't handle  our site, ant sets into loop?

There is about 20000 such requests

xx.xx.xx.223 - - [30/May/2014:13:40:54 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:54 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:54 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:54 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:55 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:55 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:56 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:56 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:56 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:56 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:58 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:58 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:58 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"
xx.xx.xx.223 - - [30/May/2014:13:40:59 +0200] "POST /billing HTTP/1.1" 500 613 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.503l3; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; MSOffice 12)"

Your Apache log format does not include any information about the time it took to process each HTTP request, therefore we can neither confirm nor reject with 100% certainty the possibility of a Slowloris attack, since this attack achieves connection pool exhaustion by initiating a large number of connections and keeping them open for prolonged periods of time.

  There is about 20000 such requests

This information is irrelevant unless you specify the time-frame during which these requests were made.

It's hard to determine from your log snippet whether this is an actual attack or not. One would need historical data in order to determine the normal usage patterns of your application before being able to make such conclusions.

The "MS Office 12" part of the user-agent string would indicate that these requests originated from an application that is part of the Microsoft Office suite -unless of course the user-agent string is spoofed by some custom bot/crawler.


Can native SQL code be vulnerable? To what? I was able to find an article that mentions that SQL injection can be done to SQL code in the following scenarios where stored procedures are involved:

EXEC statements
Dynamic Cursors

Assuming SQLi isn't directly possible (we have prepared statements and input sanitation anywhere user input is taken) but an attacker can get information into the database and SQL code processes this information (say, via a query to a table containing the attacker input), are there any other types of SQL code we should worry about?

In this case, persistent (stored) XSS has nothing to do with the actual risk of SQL Injection (SQLi). Stored XSS is one attack vector but not required for SQLi. The two golden rules of protecting against SQLi are:

Sanitize all user-supplied input (including URIs)
Use parameterized queries instead of concatenating raw SQL

Always validate your site after any code updates to ensure the expectations (assumptions) are still holding true. If you are trying to determine impact consider the following source for additional info on SQLi.

EDIT Updated to reflect updated question

Assuming you're asking if malicious code, stored as data in the database, can be harmful to the retrieving query, process, etc. the answer is: it depends. Typically, the malicious code would not be SQL syntax but HTML/JS. For this reason, it is equally (and sometimes more) important to do output sanitization to reduce the risk to the consuming entity (db, webserver, user, etc.).


Man in the middle attack still possible against ssl? I've heard about ssl strip in the past that allowed for man in the middle attacks to take place against browsers, but those vulnerabilities were patched long time ago. So my question is...are there still any form of attacks that can be used to bypass ssl encryption on sites and perform man in the middle attacks?

Also what are the precautions or preventive measures we can take to guard against such form of attacks?

Sslstrip is not an attack against SSL. It has never been. It is an attack against HTTP (not HTTPS): it looks for points where some HTTP (hence unprotected) Web site tries to switch to HTTPS, and prevents this from happening. Thus there is no SSL to begin with.

To counter sslstrip (which still works, by definition), Web sites must:

make SSL usage explicit: the human user MUST see the https:// URL in his browser's URL bar, with the padlock icon and so on;
educate users into expecting such explicit SSL usage, and bailing out in case the expected SSL does not happen.

There are no known MitM attacks against properly used SSL. "Proper usage" includes, in particular, a user who does not click through warnings about invalid server certificates. It always comes down to the user.


Single-use password as the default authentication method? The crazy password requirements (joke1, joke2) lead me to a situation where there is no way for me to memorize the passwords to the several sites that make those requirements.

The result is that every visit to those sites is a password recovery exercise (click on the password recovery link, answer a personal question, receive a text message with a code or an e-mail with a link, enter the code/visit the link, invent a password that I will never use again, finally access the site).

My question is: why can't we just skip the invent a password that I will never use again stage?

Email

Another question What are the benefits and drawbacks of emailing a user a login token/link? answers are:

It requires e-mail access on the same computer (usability)
It requires updating one's e-mail address with the site when the address is changed
It is vulnerable to an attack on a single user e-mail

SMS

It appears that these issues are not as relevant for cell phone/sms approach.

So,

Are there security issues with this approach?
Are there any sites which use this approach?

Are there any sites which use this approach?

This sounds very similar to Yahoo's on-demand passwords.

  Yahoo announced that in lieu of a standard username-password combination, Yahoo users in the US could log into their accounts with one-time passwords sent to their mobile phones via SMS message.

  Are there security issues with this approach?

Yes, like the email approach is vulnerable to an attack on an email account, this is vulnerable to an attack on a device. The device could be stolen, or if it is a smartphone malware could be engineered to access SMS messages and send them to an attacker. Also, consider what happens if the phone is lost or the SIM expired (say it was an old phone and you only just realised you needed it to access your account).

  The crazy password requirements lead me to a situation where there is
  no way for me to memorize the passwords to the several sites that make
  those requirements.

  The result is that every visit to those sites is a password recovery
  exercise (click on the password recovery link, answer a personal
  question, receive a text message with a code or an e-mail with a link,
  enter the code/visit the link, invent a password that I will never use
  again, finally access the site).

This is already a solved problem. Get yourself a password manager, protect all your accounts with a strong, memorable master password and then you can retrieve everything without remembering individual username and password combinations.


Privacy and VPN - does employer's VPN still log activity when I am connected by wifi? A company I work for wanted to use a VPN client called Junos Pulse to connect to their file server.

I am on my personal computer, and connected to my personal wifi. I was not using their VPN for internet access, but rather just to access their files.

Would my internet activity have been sent to the company through VPN? Should I uninstall Junos Pulse altogether to preserve my privacy? Anything else I need to do to ensure I'm completely off this company's network?

I have already looked at this related question:
Can my company access my computer via the VPN?

As well as some others around the web. I do understand that VPN clients will monitor your internet browsing but the part I don't understand is that in this case I wasn't using the VPN to access the net, I was still on my own wifi. So is this still the case for me?

Sign out of Junos to keep your traffic off their network, there is no need to uninstall the VPN client completely.

If you had signed in to Junos, it was routing all your network traffic through their VPN. Although you were on your own Wifi, when you logged in to Junos, it would have redirected all your traffic into their VPN.

There is a chance that they had configured the VPN client to use split-tunneling to minimize the traffic which was sent on their network. You'll have to ask their systems department to find out.

This is a link to a juniper datasheet, look under the features and benefits section.


Authenticate user just by clicking a link on external website I was just asked to allow a partners users to authenticate to our backoffice just by clicking a link in their backoffice. The only common data we have is these users mail.

I fail to see how I can securely implement this. Any insights?

It seems OAuth2 is the way to go. After a bit reading I suppose the flow must be like

give partner's backoffice an access token through client credentials grant
make them use this token by calling an endpoint which will return a link given the user's mail as parameter

The link will contain a usage-unique token which will be used to authenticate the user.

Given all calls use HTTPS I think this would be secure?

You could implement something like OAuth 2.0 (example). Basically, you have an application, authentication server, and resource server. The application wants to access your resource through an authentication/authorization server. A series of token exchanges in a particular way makes this possible to do securely.


Can IP Security camera be tampered by flash of another camera? We have been using a new IP camera (Cleverdog) to monitor work in our clothing line factory since a week. It has new features like Infrared, Motion detection, Sound and we can also give instructions through in-built speaker. The recorded footage can be viewed Live on our mobile phone like most IP Camera features.

Since today the footage looks like it's gone Pink x-Ray mode. Everything is washed out and shadows are in shades of magenta.

My question regarding Flash Light is due to the footage that we saw. From recording saved on phone and Cloud, we could make out this happened after a man appeared in front of the screen. Suddenly, screen blanked out to full white. Right after that, next frame onwards the footage has changed to burnt pink x-ray. (Sorry, I couldn't copy a screen-shot for reference)

We are now 3000 miles away from site of IP Camera and tried options given in remote settings but nothing seems to work. We have asked a friend to visit and restart Camera but are less hopeful about any change since we had restarted it via online a few times without much change in the footage.

Thanks in advance.

It is possible to destroy a CCD using very strong light or, even better, a laser (a portable green/blue laser is enough), but the result will be "dead" pixels either in spots, such as in here, or in whole columns and rows depending on the CCD architecture. This holds true even for 3-CCD and Foveon systems, since it's very unlikely for the whole surface to get burned - unlikely as it is that such a system is employed in a surveillance camera.

Your symptoms seem to indicate that the whole green channel has disappeared or is no longer encoded/transmitted.

There are some AGC troubles that will give similar symptoms, and may not recover from a reboot but need a complete power cycle. What happens is that red and blue channels are boosted at the expense of the green one.

Another possibility is that the camera is stuck in "infrared" mode (even if this is usually B&W), or both systems are running at once and interfering. Here, again, a power cycle might help, but a soft reboot should have, and yet it didn't.

But it almost looks like (a screen capture would have helped) the CCD assembly and the encoder are actually separated assemblies inside the camera, and they're connected through a VGA line... whose green wire got disconnected (e.g. by a shock). This would account for the magenta bias, even if it still doesn't satisfactorily explain the washed-out appearance. But similar problems are known and due to the CCD packaging.

Barring a very unusual internal construction of the device, I do not see a laser or a flashlight wreak this kind of havoc. Unless one took a large laser assembly and used it to smartly rap against the camera body.


Linux or Windows- the security issue Possible Duplicate:
  Open Source vs Closed Source Systems

Almost anyone who has grown up on Windows must have had the notion (that I had) of Linux being more secure than Windows- one of reasons being you don't have to worry about using an anti-virus on Linux!!

What is the basis of this notion? And to what degree is it true?

Has this got anything to do with the Open-source nature of Linux? Its community support? Its underlying architecture (and the difference from Windows)?

I'm going to knock some of the bad notions here:

1) Linux is more secure because of less marketshare.

Not in the server market, where public machines get slammed by bots, viruses, hackers, etc. all day:

http://en.wikipedia.org/wiki/Usage_share_of_operating_systems#Servers

2) Windows is more secure in recent versions.

At least at the kernel level, you're seeing more CVE reports of remote execution exploits and privilege escalation in Windows, more local DoS attacks to a multi-user environment in Linux, also you'll find more critical CVEs on Windows (I had a bunch of statistical breakdowns from a CVE database but I can't find that post I made months ago, so frustrating! Google isn't helping me find it...).

As you can see Server 2008 has a much higher weighted average of CVE severity:

http://www.cvedetails.com/top-50-product-cvssscore-distribution.php (plus, all Linux vulnerabilities from the 1.2 days vs the past 5 years of 2008 development!)

Of course you run with something like Ubuntu that comes with a bunch of software and pre-configuration on top of it, they're at the whim of the software running on it.

My opinion on the subject: Linux is built around a lot of Unix concepts, 40 years of software development and people beating these boxes to death, it is secure mainly by Unix's trial by fire, and this has helped immensely, lots of lessons were learned and directly applied to Linux.

  Has this got anything to do with the Open-source nature of Linux?

A lot of it has to do with that, at least with the speed at which the higher volume of CVEs are addressed. This also allows a lot of smaller issues to be found and fixed (mainly due to it's popularity, because open-source with no popularity means few eyes on the code and little interest to fix).

  Its underlying architecture (and the difference from Windows)?

Being built up around a multi-user environment helps a ton, these systems were built to have tons of people on them at once, and no one user should be able to interrupt another.


Can a virus persist across Windows version upgrades? It is possible for a trojan which allows a remote user to secretly control a computer, to re-install itself after upgrading to a newer version of Windows?

Short answer: Yes.
Why?

If the malware/virus is delivered via an application/file and the app/file is opened after you re-installed Windows, then the virus/malware will be reactivated.

When you upgrade, you don't do a complete re-install of Windows, you just update it (for example from Vista to 7). If this happen it's very likely that the virus will run just as well on the new version (don't underestimate the compatibility of malware and viruses).

If you are completely removing everything that's on the hard drive there's a good chance that your PC will be clear of viruses. If you however, have your Windows on C: drive and the virus/malware on another drive, it's very possible that it will come back if you trigger some part of it.
There are a number of other options, but these are the more commons I can think of. It would also help if you could clarify explain what you understand by "upgrading to a newer Windows".


Is it possible to setup a phishing “honeypot” for proof-of-concept purposes without getting the host/IP blacklisted? [Edited title according to comments]
In the company I work for we have many clients and vast majority of them have hosting with us and we made their web apps. One client though just applied for cyber security. Our CEH (certified ethical hacker) asked me to make an exact replica of client's login site to test phishing on their cloud service. All legal by contract.
I asked this same question in the wrong community where Giacomo1968 steered me in the right direction. So to be clear: The reason for the following is we had to prove to our client that their cloud login site can be replicated and published to a very similar domain, which is used for stealing login data.
I made the replica ( down to a pixel ^^ ), and backend that stores username and password (plaintext) to database and sends an email to our CEH with the phished data.
So far, so good, but during the development process (last hour or two) a refreshed and reloaded both original and replicated pages several times.
Then when I was already finished, I refreshed the original site one last time (for no reason at all), and Google Chrome sent out a known alert:

This got me worried that Google might tag our company IP as malicious, resulting in many problems for our other clients who have their websites reachable at our IP address.
I have HTML markup linked with some CSS and JS and in the JS I use Fetch API to call a PHP script which in turn stores username-password combination to database along with NOW() and then send an email with PHPMailer.
Should the phishing site have some tags or something which tell Google it's a cyber-security test or perhaps I'm going about the wrong way entirely. Or, hopefully not, there is just no chance and one should never put such code on server. If so, how do you test this locally if intended users can't browse there?

Lock the site to your target IP range and display a benign placeholder ("coming soon" or "it works" or even a 404 error) to any client outside that IP range. (This is the easiest way for real world phishing to prevent listing by crawlers and it is a pain to those of us that are trying to keep the world safe.)
This will not, however, prevent listing from phishing detectors that can draw conclusions without crawling your site (e.g. by the look of the URL or DNS metrics).


Is there any technical security reason not to buy the cheapest SSL certificate you can find? While shopping for a basic SSL cert for my blog, I found that many of the more well-known Certificate Authorities have an entry-level certificate (with less stringent validation of the purchaser's identity) for approximately $120 and up. But then I found that Network Solutions offers one of these lower-end certs for $29.99 (12 hours ago it was $12.95) with a 4-year contract.

Is there any technical security reason that I should be aware of that could make me regret buying the lowest-end certificate? They all promise things like 99% browser recognition, etc. I'm not asking this question on SE for comparison of things like the CA's quality of support (or lack thereof) or anything like that. I want to know if there is any cryptographic or PKI reason so avoid a cert which costs so little. It, like others, says that it offers "up to 256 bit encryption".

For the purposes of this discussion there are only a couple differences between web signing certificates:

Extended vs standard validation (green bar).
Number of bits in a certificate request (1024/2048/4096).
Certificate chain.

It is easier to set up certificates with a shorter trust chain but there are inexpensive certs out there with a direct or only one level deep chain. You can also get the larger 2048 and 4096 bit certs inexpensively.

As long as you don't need the extended validation there is really no reason to go with the more expensive certificates.

There is one specific benefit that going with a larger vendor provides - the more mainline the vendor, the less likely they are to have their trust revoked in the event of a breach.
For example, DigiNotar is a smaller vendor that was unfortunate enough to have their trust revoked in September 2011.


changing defaults when generating new SSH server keys On Debian, I can generate new SSH server keys:

rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server

but that will generate the keys with default values, ie 2048 RSA key.

What is happening under the hood, when I execute dpkg-reconfigure openssh-server ?

How can I change these defaults (ie, rsa to 4096), when generateing new server keys ?

Run this (as root) instead:

#!/bin/sh

# clean up old keys or complain you're not root
cd /etc/ssh && rm ssh_host_*key* || echo "Run this as root!" >&2 && exit 2

# generate; see https://stribika.github.io/2015/01/04/secure-secure-shell.html
ssh-keygen -t ed25519 -f ssh_host_ed25519_key -N "" < /dev/null
ssh-keygen -t rsa -b 4096 -f ssh_host_rsa_key -N "" < /dev/null

# zero for untrusted keys (prevents their recreation with dpkg-reconfigure)
touch ssh_host_dsa_key ssh_host_ecdsa_key

# restart ssh
service ssh restart

I disabled DSA (which is highly insecure) and ECDSA (which has less worrisome risks, see prior link or Secure Secure Shell).

dpkg-reconfigure will not touch your pre-existing keys (I see you recognized this, that's why you ran rm first). In fact, it's not even necessary to reconfigure; a simple service ssh restart should suffice.

If do this manually, you can preserve your existing ed25519 key; the defaults are good for it.

All clients' ~/.ssh/known_hosts files for this host will now all be wrong. You can just replace the matching entry after the first space with the new .pub file or re-verify the signatures. I do that with ssh localhost on the server (and I always say "no") to get the hash, but the "right" way to do it is:

ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub


Attack vectors for server to server using untrusted HTTPS certificates? I have noticed a large amount of server-side HTTP client libraries accept untrusted TLS communication by default. For example, from the documentation for node's request:

  strictSSL - If true, requires SSL certificates be valid.

This is false unless set, in other words, untrusted SSL certs are accepted by default. I'm not specifically picking on request, it's by no means alone when it comes to this behaviour.

What are obvious attack vectors for server-to-server communication (typically a REST API) using untrusted SSL certs?

Eg, DNS cache poisoning could be used to replace the real endpoint with an attacker's replacement that uses a self-signed cert.

Are there others?

When a client doesn't check the SSL certificate of the server that it is connecting to, this opens the door for a Man In the Middle (MITM) attack.  As the name implies, this type of attack is pulled off by someone between the client and the server.  In practice, there are a number of scenarios where this can take place.  See How does a Man In the Middle attack happen in reality for more info.


Can a speaker be used as a microphone? From LWN's security quotes of the week:

  These days audio hardware usually consists of a very generic codec
  containing a bunch of digital→analogue converters, some
  analogue→digital converters and a bunch of io pins that can basically
  be wired up in arbitrary ways. Hardcoding the roles of these pins
  makes board layout more annoying and some people want more inputs than
  outputs and some people vice versa, so it's not uncommon for it to be
  possible to reconfigure an input as an output or vice versa. From
  software.

  Anyone who's ever plugged a microphone into a speaker jack probably
  knows where I'm going with this. An attacker can "turn off" your TV,
  reconfigure the internal speaker output as an input and listen to you
  on your "microphoneless" TV. Have a nice day, and stop telling people
  that putting glue in their laptop microphone is any use unless you're
  telling them to disconnect the internal speakers as well.

  — Matthew Garrett

I can't tell if Garret is being serious here. While an audio chip being a generic converter makes sense, I don't see how an average speaker can convert incoming audio into useful signal. Are speakers that sensitive?

Can software be used to operate an average consumer speaker as a microphone?

One simple experiment you can run is to plug your headphones into a microphone input and speak into them.

Fundamentally, both emitting sound and capturing sound is about dealing with vibrations in the air. The processes are opposite (one takes electrical signals as input, and outputs air vibrations, one takes vibrations in the air and transforms them into electrical impulses).

However, consider the following:

Both mics and speakers (or headphones) have a diaphragm, and as mentioned in the Wikipedia article:

  Microphones can be thought of as speakers in reverse

Both incorporate circuitry able to translate vibrations into electricity (or vice versa). In other words, both have an electrical signal on one side, and vibrations on the other. The difference is what is labelled as input.
If you think about the original phonographs, the same component was used to record and listen to sound.

So yes, a speaker can pick up vibrations (albeit sub-optimally), and a microphone can emit vibrations (albeit sub-optimally).

Many TV speakers are actually speaker arrays, too, so that you (sort of) have an array of tuned inputs (important because it might allow using post-processing to enhance the wanted audio).

This doesn't address the software question, but mechanically, a speaker can function as a microphone.

There is also "proof" that the functionality can be abused: badBIOS used the built-in PC speakers as a form of high-frequency modem—this despite the fact that one would expect PC speakers to be wired only for output. So yes, your comment was correct—there is a link to information security, and the functionality can be abused, notably to bridge air-gaps.

So this seems possible—how practical and how effective is another question, but there is precedence that it is usable for certain applications.

Edit: Thanks to @nulldev, "how practical" seems to have a fairly conclusive answer: per Arxiv, it is practical, and software solutions exist.


Enterprise level password hashing I need to create some hashing classes (C#) for a login service where (unfortunately) the passwords needs to be stored in SQL server database. In the past I've been using BCrypt or PBKDF2 but there are some concerns. This is for an enterprise level solution running in the US. I see 3 valid paths that I'd like you to comment on.

BCrypt: Is not a NIST standard and that would probably be required for some customers. I'm also reluctant to use BCrypt for enterprise level software because I need something that is backed by a large company or some dedicated developers. All I can find are some (old) implementations that are maintained by one guy in his spare time. Should that not cause some concerns? I mean while the algo it self is great, the implementation might not be. And surely has to be maintained.

What are the 2016 iteration (workfactor) recommendation - 12?

PBKDF2: The only solution I can find for C#, is Microsofts "PasswordHasher" (or similar Rfc2898DeriveBytes implementation). The released version is using HMAC SHA1 with 1000 iterations. This seems invalid in 2016. There is a newer version here, but that seems to be a prerelease in Nuget. In any case that is also just using HMAC SHA256 with a static iteration count of 10000. Where I would expect this to be at least 256000 in 2016. Also if you look at the code the implementation calls some Win8Pbkdf2Provider behind the scenes which tends to be BCrypt derivative (making my NIST requirement hard anyways).

SHA1 + AES: An alternative approach would be to just go with standard Rfc2898DeriveBytes using HMAC SHA1 and then using AES to encrypt the database values - storing the AES key on disk. I like this approach the best actually but if you search these things, that solution never surfaces so I might be be missing something...

What do you guys recommend? What do you do when looking into securing enterprise level software?

What are your actual requirements? "Enterprise level" doesn't say much, at least no more than it will be a large project. If NIST is a requirement, then PBKDF2 is all you've got. From a security perspective, I would recommend bcrypt, as it is slightly more secure than PBKDF2 which is based on SHA variants. bcrypt itself has baked long enough to be a good alternative to PBKDF2, even though the NIST doesn't say anything about it (yet).

When it comes to implementation, you really should use a well-established library. You don't want to manually check the implementation details and neither should you. A quick search revealed that there are several bcrypt implementations for C# that are well supported in the C# community.

For more details about PBKDF2 vs bcrypt also see the answer by Thomas Pornin.

Update

I wouldn't go with the SHA1+AES option. Doing this will not actually resolved the problem, but only mitigate the risks for certain types of attacks. Still if the application somehow were to leak database contents, you can only trust on SHA1. It feels to me like a hack, and the last thing you want is to cook up something yourself.


When should I use Message layer encryption vs transport layer encryption Basically I will be having to secure a connection between different hops. Therefore even if TLS is widely known to be the best in class, I am wondering that in such a case message based encryption wouldn't be worth more than transport layer based encrypion? If yes please help by listing some message layer encryption algorithms.

I'm confused about what you are asking, and I think you might be a bit confused about some of the concepts, so let me try to guess what you might be getting at and see if I can clear this up.

I think you are asking about the difference between end-to-end encryption vs hop-to-hop encryption.  In end-to-end encryption, the sender encrypts it, and then the encrypted message can traverse over multiple hops, but the multiple hops do not have access to the message; the ciphertext is not decrypted until it reaches the final recipient.  In hop-to-hop encryption, each hop decrypts and then re-encrypts it for the next hop).  Generally speaking, end-to-end encryption is preferable, because it avoids the need to place any trust in the intermediate hops.  So, try to use end-to-end encryption whenever you can.

TLS can be used for either end-to-end encryption or hop-to-hop encryption.  That's an orthogonal issue.  It just comes down to which two nodes you declare to be the endpoints of a TLS connection.


Does encrypting a file make it larger? I encrypted a Word document using Winrar by setting a password. Surprisingly the archive was larger than the original file (631 vs 614KB). I then tested to see what would happen if encryption wasn't used and the result was a 612KB archive. Why is this?

Now that TrueCrypt is gone what's the best way to encrypt data to be saved to the cloud (e.g. google drive)?

Encrypting does not inherently make a file larger.

However, in practice, encrypted files are larger than their non-encrypted counterparts for a number of reasons:

Symmetric ciphers in current use have the property that every possible ciphertext can be decrypted to a plaintext, or in other words, if somebody tampers with the encrypted file, it can still be decrypted.  If you're encrypting a file, you usually want some assurance that the file hasn't been changed while you weren't looking, and this requires adding extra information in one form or another.
Most symmetric ciphers work on blocks of data considerably larger than a single byte (AES-128, for example, works 16 bytes at a time).  As a result, if the file isn't a multiple of the block size, you need to pad the end to fill a complete block.  There are ways (such as "ciphertext stealing") to do this without making the encrypted file larger than the original file, but just adding a few bytes of padding is usually simpler.
There are many different ways to encrypt a file.  It's often useful to add a header to an encrypted file describing how it was done (what algorithm was used, what tamper-prevention mechanism is in use, how the password was expanded to produce a key, and so on).  In theory, this reduces security by providing information to an attacker, but in practice, the increase in convenience outweighs any minor reduction.


Is there any security benefit in stripping only `` tags that contain code? On a client's corporate network something is stripping all <script> elements that contain code, i.e. things like <script type="text/javascript">do_something();</script> will simply be stripped from server response before it reaches the browser. SSL doesn't help (and of course, the certificate appears broken even though it's perfectly valid).

On the other hand, HTML elements like <script src="/something.js"></script> aren't getting stripped and run in the browser just fine.

My question:

Is there any security benefit from such stripping?

I certainly can't see one... XSS comes to mind, but if someone is going to do a XSS attack, they'll probably try the variant with src, no?

And a side-question: what software could they be using? Or better yet, what can I use to emulate that situation on my Mac or PC where the development happens?

No, stripping <script> tags is useless because you could  still execute a javascript payload like this:

<input onmouseover=prompt(document.cookie)>

And bypassing the filter should also be quite easy, imagine what would happen if a payload like this sent:

<scr<script>ipt>

As far as what type of software they are using, well there's just not enough information to determine that. What you could do is request the robots.txt and see what this discloses.

In order to simulate / test this, you could use the following code as an example:

<?php

if (isset($_GET['q']))
{
   $var = $_GET['q'];
   $var = str_replace(array("<script>", "<script src"), "", $var);

   echo $var;
}
else
{
   echo "GET parameter 'q' is not set!";
   die();
}

?>

The solution to this problem is input validation and output encoding. Here's an OWASP resource that I recommend reading: https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet


Are documents truly "signed" by DocuSign? I've never been happy with the explanation DocuSign gives for themselves in their own marketing material (e.g. https://www.docusign.com/how-it-works/electronic-signature/digital-signature/digital-signature-faq, https://www.docusign.com/products/electronic-signature and https://www.docusign.com/how-it-works/security). I have a number of questions:

For me, if I want a document to be signed, I need to encrypt the hash of the document with my private key, and any recipients can verify the signature by  decrypting my signature's hash and comparing it with their own recompute of the hash. On DocuSign I cannot see where or how I can provide my own private key (which would be a huge security issue in itself) nor will it let me keep my private key private (i.e. on my premises, not uploaded to their server). There is also no mention of any public key - in fact there's no way for me to verify the integrity and authorship of any document as DocuSign simply doesn't give that type of metadata to me, I just have to take their word for it that the document hasn't been tampered with.
How does DocuSign verify identity in a meaningful way? So far all I can tell is that they can verify email address ownership (or at least mailbox access), I don't remember ever being required to verify my identity by  driving license or passport scan uploads - so how is that legally considered proof-of-identity? How is it a signature in any way if it cannot provably be linked with my real-life identity? Anyone could claim one of my expired Hotmail addresses and create a DocuSign account for me and sign things with it.
I have a problem with DocuSign being simultaneously 1) the verifier of identity, 2) the holder of the documents, and 3) the generator of the signatures - the fact it's a single legal entity means they have the legal, and certainly the technical, means of altering any document, its signature, and claims about that signature; considering recent news events where certain first-world nations governments try to coerce companies to decrypt their data this means I'm not likely to consider DocuSign trustworthy enough to "sign" anything significant. There is also the fact that DocuSign's codebase is proprietary and not accessible - I have to take their word (on their homepage, no less) that they have been independently audited and that the audit means something.
I also don't like how they generate a fake handwritten "signature" image - I thought it has been established that simply having a photo of anyone's handwriting next to some text does not constitute a signature. I'm concerned of the effect this may have on users: a kind of "CSI effect" where the crypto-layperson will think that a picture of their signature is enough and then apply this learned "fact" to other platforms, thus worsening the public's awareness of PKI (after all the progress we've made educating users about SSL).

Given the problems I think found in DocuSign above - if I were involved in a legal case, such as a contractual dispute, and the version on DocuSign is brought as evidence - can either party in the suit legitimately claim that the DocuSign document is bona-fide, conversely how easily could the other party show the "signature" cannot be trusted?

i.e. can anyone sum-up DocuSign's service and categorically say if it's cryptographically, or at least legally, sound?

A signature is, ultimately, a legal concept. When you sign a document, you are really producing a legal gun aimed at your own head (so you usually want other people to sign things, not sign them yourself). The value of a signature comes from its legal power, i.e. how much it will allow to apply responsibility and blame on the signer. The cryptographic elements (RSA and so on) are only tools that can help build the technical side of things, but that cannot suffice. Ultimately, there must be some kind of legal framework that defines signatures.

Of course, this will depend on jurisdiction. Nevertheless, countries/states that are currently defining laws for electronic signatures tend to go along the same lines:

A signature is binding as long as it was really signed by the alleged signer. This looks tautological, but it is an important definition: it really says that the signature legal value is not intrinsic to any specific technology. Writing your name at the end of an email is a signature.
What matters is the burden of proof. Legal frameworks will normally segregate systems into two categories: those for which signatures are reputed good, and it is the party who denies having signed who must make all the proofing work; and those for which signatures are reputed worthless unless a positive proof of attribution to the alleged signer is shown. "Name at the end of an email" belongs to the latter category; a positive proof may be simply a witness who saw the signer type the email.
The reference for signatures is handwritten signatures, which are, technically speaking, absolutely terrible. They are hard to validate, and can be faked. Handwritten signatures are still used thanks to a legal framework that severely punishes anybody who denies his own signature. Since handwritten signatures occur in the physical world, the very act of signing (with a pen) leaves a lot of traces (witnesses and so on) so many people ultimately find that repudiating their own signatures is too risky.
A further complication is that legal systems of the "Common Law" tradition tend to rely on jurisprudence to iron out the fine details, so countries like USA and UK will likely have legal frameworks for signatures that boil down to "wait and see" ("see you in court", I mean).

In France (which has a very "Latin" law system that really likes pre-established rigorous definitions, Descartes-style), the legal framework defines systems which are qualifiés, by which they mean that they went through independent audits and an administrative process that has all the simplicity that can be expected from French bureaucracy, to the effect that for this systems, the burden of proof lies on whoever claims that the signature is not binding. The list of the systèmes qualifiés is published and I see no DocuSign there [edit - as of July 21, 2017, DocuSign France is now listed].

DocuSign has a page dedicated to the legality side of things -- which is in fact a lot more important than the technology. In particular, they say this:

  While DocuSign has a successful history of providing customers with all the evidence they need to defend their documents against repudiation, DocuSign is available to assist our customers with legal challenges by testifying in court to support the validity of DocuSigned documents.

which implicitly admits that their system tends to be of the "must prove validity" kind, i.e. not the one you would like -- but they claim to have had good results in some courts, and that they will help you. At that point, I'd say that if you want to use DocuSign for making your customers / business partners sign things, you'd better make sure that there are appropriate clauses in your contract that ensure a strong level of help from DocuSign, with insurance and so on. Your lawyer team should be involved.


PCI Compliance - Antivirus in host and virtual environment? We have a couple servers with a host system, and virtual DB and Web instances. Is it possible to be compliant with PCI if you install the Antivirus only on the host system, or does it need to be installed on all three (host, db instance, web instance)?

By installing it on the host, doesn't it scanning the virtual servers as well (bin, vhv, and vhd files)? Or can the antivirus not scan/get to the details necessary when they are embedded in the virtual machines?

If we can't just install it on the Host OS, could it be installed only on the Web instance since that is the only one that is publicly accessible?

Just trying to avoid the extra CPU/RAM footprint of installing in all 3 instances if possible.

Not sure it makes a difference, but this is in a Windows 2012 Hyper-V environment.

If, by installing the anti-virus solution on the host system, you can achieve the same level of protection to the VMs as you would if they had anti-virus installed individually, then the end result is that all systems are protected from malicious software. This would satisfy compliance. There are very few products in the market that can be installed at the host level to provide protection to VMs.

The PCI DSS requires that anti-virus be installed on systems commonly affected by malicious software. This is prescriptive rather than risk based so the fact the db instance is not publicly accessible does not mean it falls outside this requirement. It would still need to have anti-virus installed unless the operating system for that VM is one not commonly affected by malicious software.


Where can I practice MITM raw binary protocols? I want to try practicing MITMing raw TCP binary protocols as well as MITMing HTTP protocol. What is the best way to do this? Are there any specific tools which help me do this? Like wireshark or ZAP or Burp suite?

Burp suite is by far one of the best tools to learn about http protocols and it can also help you in MITMing attacks.


VPN detection with installed client I would like to know:

How can they detect the VPN? Does installing the client mean they can see background processes and see the VPN software? Or is the only way that they use a blacklist of known registered VPN IPs?
Is there anyway to prevent this detection? Would using a kind of sandbox like VMware player, with the client installed inside but the VPN setup outside the sandbox be sufficient? Would setting up the VPN via the router itself, rather than software be better? Or even setting the VPN up on a smartphone and tethering perhaps...
Will installing my own OpenVPN on a VPS be a more secure option? (since this won't be on a blacklist of VPN IPS presumably)
Any other methods of detecting I'm on a VPN that I am simply unaware of?

They could try using background processes to check for VPN usage, however I strongly suspect that is not the case for two reasons:

Too much effort. Devs are lazy and an implementation like this would take a lot of effort (I wouldn't expect a simple poker game to do this).
Not everyone uses the same client (PIA, OpenVPN, Securpoint, etc.), though if they wanted, they could just target the most comment clients.
Like you mentioned, you could just use a VPN on another device and then bridge connections if you were really determined.

I would think that they would be using blacklists, in which case renting your own VPS will probably work, unless the VPS is already on a blacklist. If they are using blacklists, then you could try looking around to see if maybe there are VPN providers that aren't on the blacklist, but that would be hit and miss, so I wouldn't try it unless you could get a free trial type deal during which to test the program out on.

It's really pretty hard to detect VPN usage, and I haven't heard of any cases in which the implementation you mentioned with the system process monitoring has been enacted. If this is the case, you could try to circumvent it using what I listed above, or rename the process.


Sending Mail Using TLS I run a simple web service, and I need to securely send emails to users via PHP.

There are no mailboxes/accounts involved. It is a simple send-only function.

Without involving PGP, I have come up with the following options -

Use local SMTP server and configure outgoing TLS (could still travel via plaintext across the internet?)
Check user's email address. If its @gmail.com (or hotmail/outlook/yahoo) then send to Gmail/Hotmail/etc SMTP server using TLS (pretty likely to be encrypted all of the way?)
Any other options?

Appreciate any help/thoughts.

I run a simple web service, and I need to securely send emails to users via PHP.

Your exact requirements of "securely send emails" are unknown. But none of your proposals offers end to end security, i.e. depending on the path one or many parties can intercept and even modify the mail.

In detail:

SMTP has only hop-by-hop encryption, which means any MTA on the way will have the mail in clear even if TLS was used to transmit the mail to the MTA.

Also there is no guarantee that TLS is used at all because SMTP transfer starts plain (without encryption) and only gets upgraded optionally to TLS with the STARTTLS command. If this fails or if no STARTTLS is offered by the receiving MTA the mail is usually send plain text (i.e. best effort encryption). There are various ways TLS can fail (bad configuration) or can be made to fail by an attacker and there are also firewalls which simply transparently strip STARTTLS support so that they can look into the mail.

Apart from that the next hop MTA is chosen by the DNS MX record. With DNS spoofing the mail can thus be redirected/intercepted unless the sending MTA is using strict DNSSec, which it usually isn't.


FIN Attack- What is this type of attack really? I just wanted to know what exactly is the FIN attack. I know about the FIN flag that is used to indicated the closing of a connection via TCP. But what exactly is FIN attack?

It's an older attack originally intended to be a "sneaky, firewall bypass" that was dependent on a few factors that are now uncommon today: old Unix OSes, lack of stateful firewalls, lack of NIDS/NIPS, etc. It can still be useful when testing (i.e., as a fingerprinting technique not an attack per se) completely new or novel TCP/IP stacks (or just new to you or your environment), which is rare but can happen.

Here is a modern replacement, the TCP protocol scan:

nmap --reason -n -Pn --packet-trace -g 80 -sO -p 6 <target ip>

Which is almost exactly the same as the TCP ACK scan (which can be used to map hosts, open ports, firewall rulesets, etc with the caveat that some NIPS, IDS, and modern firewalls will detect -- with another situation-specific event where perhaps it will not notify incident responders or Security Operations Centers because they have more important things to look at these days):

nmap --reason -n -Pn --packet-trace -g 80 -sA -p 80 <target ip>

But the outputs are slightly different and you can see the other packet-level differences as well.

What you are looking for in order to develop a more advanced technique is to identify the subtleties in the RST packets and their window sizes. If you get non-zero window sizes, then you may want to switch to using the TCP Window scan instead of the TCP ACK scan. For more information, see http://nmap.org/book/man-port-scanning-techniques.html

Some other techniques are found in the NSE guide, such as the firewalk and firewall-bypass scripts. However, there are many other techniques including BNAT, fragroute, osstmm-afd, 0trace, lft, and potentially others that detect other inline, non-firewall devices such as WAFs, IDS, IPS, reverse proxies, gateways, and deception systems such as honeypots or active defenses. You will want to be aware of all of this and more if you are performing a network penetration test, but they come in handy for troubleshooting all sorts of network and security issues.


Getting access and logging into employee's laptop - Can IT get access without the employee's own credentials? If an employee's laptop is taken back from him/her for purposes of investigation, can the IT department/team that is in charge of issuing laptops etc. log into the employee's network account on this laptop on their own or does the employee need to provide his/her credentials

This question is not actually specific enough to answer definitively.

Are you asking if they will be able to login to Windows on the computer using a domain account? (Yes, they can just reset your password)

Are you asking if they can access information contained on the laptop? (Also yes, unless there was encryption that you configured and only know the password to).

Are you asking about some other "network account"? (Still probably yes, businesses like to be able to manage employee access to products like this, which often involves resetting passwords)


The difficulty of securely storing a password We have an open source software that allows users to be created. The users are saved in an LDAP directory. The software connects to the LDAP as an administrator to write a new entry for a new user, or to edit the password if the user wants to change his password. To do this, the LDAP master password must be stored in the software. Now, this password is valuable, where valuable means, if it gets into the wrong hands, you have to call the police within hours. Therefore the suggestion was made to store the password reversibly encrypted with salt. However, for me this does not come out on a remarkable improvement, because the key for the encryption must also be stored on the system, as well as the salt. If an intruder has root privileges on the system, he can read the encrypted password, key, and salt, and with the open source software application, with a little programming knowledge, he will have decrypted the password shortly. I think about the best way to solve this, but no matter which technology you use, the associated key must always be stored on the system, so it is just as vulnerable as before. So the question is essentially how do you make the application have the key, but it is not stored on the system?
The application is old and has a lot of memory leaks, so it has to be restarted automatically every night, so just keeping the key in memory is not a usable option. The key must be permanently available, even after restarting the server.
Edit:
The web application is in Java (EE), running on both Windows and Linux, but it the majority of users uses Linux, and for a high-security environment this could be made a requirement. However, a platform-independent way is better. The application starts with the server and is running all-time, so it can keep values in the memory.
An U2F dongle might do the job, I had not thought about that option at all yet. Thanks for the hint.

If you're not worried about malicious insiders, here's what I'd do:
Issue each authorized user a flashdrive with a file on it. The file contains the "password" (ideally it should be too long and random to easily memorize or type, so not really a password in the usual sense). The drive is encrypted using a full-volume encryption method (BitLocker, VeraCrypt, etc.) and each authorized user has their own passphrase to decrypt their flashdrive. The software reads the LDAP "password" out of the file, once the flashdrive is installed and unlocked.
Advantages of this system:

The LDAP admin password can be completely beyond human ability to memorize.
The password copies are stored on physical objects that are easy to maintain an inventory of.
An attacker who steals a user's flashdrive hopefully won't know the passphrase to unlock it, so they can't decrypt the key.
An attacker who guesses a user's passphrase hopefully can't access their flashdrive, so they can't use the passphrase for anything.
In theory, each user could have a unique "password" for LDAP administration, allowing monitoring of usage and easy disabling of individual accounts at need.

Disadvantages:

Kind of a hassle both for the users and for the IT folks who need to create and manage all these flashdrives.
Changing / rotating the LDAP admin password is a mess, especially if everybody shares the same one; all the drives need to be updated.
More common for people to get locked out because they lose a small object or forget a passphrase than if they only needed to keep track of one of those things.
A malicious insider can just unlock their flashdrive and then copy the file contents out of it, trivially (or probably just decrypt the flashdrive).

You could also use hardware tokens, but most of the advantage over an encrypted flashdrive there is the ability to make the secret non-exportable. Unfortunately, that would prevent having the secret be a password, which must be transmitted in some form. That puts a real damper on how hard you can hide it, and in particular makes it totally impossible to hide from an insider.

IF at all possible, don't use a password here
Establish the connection using some form of public key cryptography. Mutual TLS, SSH with public key, whatever. Use a system where there's an unpredictable string to be signed or decrypted, and proving that you have the private key is used for authorization. Then use a hardware security module (HSM) to store the private key, and make sure it's not exportable. The key can now never be extracted, so the only way to use it is if you also have access to the HSM. Depending on your needs, this could be an HSM that is given to every authorized user or that is only available by checking out one of a limited number (possibly only 1) from a trusted source, and it could be relatively tied to computer hardware (such as the TPM in a PC) or portable (such as a Yubikey).
For extra security, you might protect access to the private key with a passphrase or other secret, turning it into effectively a two-factor authentication requirement (the attacker needs both to have the HSM, and to know the string that unlocks access to its key). SSH and GPG private keys already typically are encrypted using password-derived keys, but there are better systems than those use.

You can't do anything about an attacker with root access to a machine where the software runs. If the software can communicate with the LDAP server, the attacker can tap that communication, edit it to serve their own purposes, initiate it on demand, etc. Even if there's no post-authentication session token to steal, and the authentication sent on every request is done without exposing the secret (e.g. instead of a password, you use a symmetric key to HMAC the message or a private key to sign the message, and the key is stored somewhere the attacker can't read like inside an HSM), for as long as the attacker has access to the compromised system they'll have full control over its communication with the server, and you can do a LOT of damage in a short time.


Is there anything like a standard GUID to identify a PC? I am asked about my opinion in a case as follows:

Someone visited a (totally legal, in fact US government) website A and identified themselves. At a very different point in time they - allegedly - visited a (doubtlessly very) illegal website B.

US law enforcement claims there is no doubt that the access to B was by the same person/from the same PC as the access to A. If the identification were based on the client's IPv4 address (outside the US!), say, I'd argue that these are typically reassigned to new client's every few hours or days (not to mention shared/NATed use by multiple entities, including WiFi guests), hence is at most very weak evidence. In addition, it currently seems that the non-US ISP was not asked to reveal the identity of their customer associated with the IP in question at the point of time in question. Rather the claim of identity is by comparison with said access to A.
Meanwhile, it seems that the identification is not claimed to be done by IPv4 address, but rather by something referenced as a "GUID" identifying the PC.
I am not aware of a standard or wide-spread use of any such GUID in any internet protocol that would allow cross-site identification between sites that do not even wish to collaborate on such an issue.

Note that the term GUID was specifically mentioned, i.e., we are not talking about browser fingerprinting or cookies.

Q: Is there anything "GUID-like" that can act as described to identify a PC/device across multiple unrelated(!) sites? In TCP? In http? In TLS? "Anywhere else" in the process?

There is no universal GUID that uniquely identifies a computer. It's not possible either, strangely for philosophical reasons.

If you know what the Ship of Theseus is, then feel free to skip this part, as you know where I am getting. Otherwise, imagine me having a computer. As it gets older, I sell parts of the hardware (e.g. graphics card, RAM, etc.) to upgrade it. At some point, none of the original parts remain. Is it still the same computer?

Further, what if someone happens to buy all the obsolete parts to assemble another computer. Would that be my computer then?

It's not a question we can answer, because "a computer" is not an atomic entity. It's a composition of various pieces. Each individual piece can uniquely be identified (serial number, etc.), but the composition can not.

Of course, you could take one piece of hardware (e.g. the motherboard) and use that as the identity, but at that point you require every motherboard to have a unique identifier.

What could they possibly have used?

That's a tough question, and it depends on the details of the scope. One possible candidate would have been third-party tracking cookies. ISPs can use the connection being used to identify customers (not individual devices though), and there have been several instances where ISPs have been found to use such things to track customers.


Cell phone voice mail hacking The news has been filled recently with the allegations that News of the World employees hacked into the voicemail inboxes of celebrities and crime victims. What flaw was exploited to accomplish this, and what is the risk to other cell phone users?

According to this New York Times article, there were a couple of methods used.

The first was a simple password guessing attack by trying the operator default PIN, and the second method was a social engineering attack against the mobile phone network operator.

The password guessing attack is simple to mitigate against simply by changing the default PIN, the main UK operators have already set up procedures to mitigate against the second attack method

  Orange, Three and T-Mobile no longer
  provide default voice mail pass codes;
  users must set their own. O2 and
  Vodafone will allow codes to be set
  only from the cellphones they supply.
  If that number is reset, the new code
  is also sent directly to the phone.
  Vodafone alerts customers if three
  failed attempts are made to enter the
  number, and O2 locks voice mail
  services.


Linux whitelist-based Mandatory Access Control instead of a blacklist-based model I'm trying to harden a Linux installation on a personal computer - I decided to try both SELinux and AppArmor as a Mandatory Access Control (MAC) to supplement the default Discretionary Access Control (DAC) that Linux comes with by default.
However, after having played around with both solutions for a couple of days it seems to me that both of them have roughly the same model of security:

All programs are unconfined by default.
You define a security profile where you define access rules and permissions for a program.
You enforce the security profile which restricts the program's access/permissions.
Repeat this for every program you want to restrict.

This model is a targeted security model where you define a specific security profile for a program based on paths (AppArmor) or object labels (SELinux) that it can access.
This seems quite odd to me, as what I would expect intuitively is a security model like so:

All programs are fully confined by default (i.e. can't do anything on the system)
You define a list of programs you would like to whitelist (e.g. coreutils, system daemons etc.) or loosen the restrictions for programs that you trust (e.g. editor, package manager etc.)
More specific profiles take precedence over the less specific profiles (i.e. /usr/bin/foo takes precedence over /usr/bin/*).
When a new program is installed - the default profile is automatically applied to it and you need to manually loosen the restrictions / whitelist it to increase the access permissions of that program.

This model applies the maximum security globally - where every program is confined by default - and uses the whitelist approach to expand the capabilities of a specific program or a list of programs as per your requirements.
As far as I know the first model is how both AppArmor and SELinux function by default. Is there a way to implement a MAC security layer in Linux which follows the second approach? I would like to maximally restrict all programs by default unless I specify otherwise - as this seems to be a better security model in my opinion and is how I would expect the MAC layer to work intuitively.

I seem to have found what I was looking for - using AppArmor global profiles and profile stacking which can be used to implement a whitelist-like model:
https://gitlab.com/apparmor/apparmor/-/wikis/AppArmorSystemWideRestrictions


Is RC4 banned from TLS for good? According to RFC7465 RC4 is banned from TLS and my question is : Is it banned for good, does any site can use it now and if it does, will I get any notification from Chrome?

RC4 has been deprecated, and is unlikely to ever be used again. There's no reason to go back and improve an old cipher when we have newer alternatives like AES, and in RC4's current state it should not be used. Some sites do continue to have it as a supported cipher suite. However, if you are using an updated version of Chrome, Firefox, or IE 11, then you will be unable to connect to the server via RC4 because they have all removed support for the cipher.

Sources:
https://blog.mozilla.org/security/2015/09/11/deprecating-the-rc4-cipher/
https://blogs.windows.com/msedgedev/2016/08/09/rc4-now-deprecated/#5weuUm0EqMr6WIE8.97
https://codereview.chromium.org/2030263002


Why should I sign git commits/tags? Should I sign both commits and tags? Easy question, but no one has asked it here as far as I see: Why should I sign git commits?

To give some more things to answer there is also this question: Why should I sign git tags (releases)?

And finally: Should I sign both? Why, why not? What is good/bad if I only sign commits/tags?

Why is it useful?

Generally it is all about thread models.
And there are several examples in the past, where it would have helped. E.g. gitea introduced it after their bot account has been compromised.

It is useful to prevent modification of your source code on your git hosting service/server (GitHub, GitLab, Gogs/Gitea etc.) and at the connections to them.

What to sign?

Now for users of your software it may be useful to e.g. download signed release tags and verify them, so they can be sure you created the source code and stuff like that.
Keep in mind though that signing release tags helps nothing if you then distribute your binaries unsigned. In most cases users prefer the ready binaries and thus would not be able to verify their authenticity.

It may also make sense to sign git commits if users may regularly use the master branch directly for downloading/using the software. They may e.g. be more common when it's just a PHP project you can clone and it works out of the box than when you have to compile it, where many users may rather use compiled binaries.

However signed git commits may also make sense for developers, as you they can verify nothing malicious got introduced in a git commit (at least not without a committer/contributor doing that deliberately or signing off something accidentally). As such, if there is something wrong with a commit you can be sure it's the one who committed it that has introduced that. (as you can otherwise just set your git username and mail arbitrarily)
However, this is really only useful if all committers to the main branch do sign their commits and thus may be cumbersome.

Attention: Remember when signing git commits you have to do it for each commit. Some workflows accept that you create a feature branch and then sign only the merge commit, but this has to fit your workflow.
In any case this also means that you often have to use your private key and have it (unlocked) in your development environment. This may not be ideal from a security perspective.
In contrast to that when you make a release with a signed git tag, you likely do that not so often, so you can use a separate device/VM/sandbox/user/…, where you do not have so much untrusted development code running, but just clone/pull the repo (with git pull --verify-signatures obviously if you've signed your commits to make sure nothing has been mangled with it) or transfer the whole git repo somehow else (in an "integrity-preserving" way) where you can sign the tag with a signing key kept in a more secure place.
This way your signing key is at least not at risk of getting compromised if your development machine should get compromised.

Conclusion

Signing git tags is (IMHO) more useful than signing commits, as the first is what users of your software will mainly use, while the latter is mostly good for developers and has it's risks (as discussed above). Thus it makes also totally sense to use different git signing keys, one for your releases that is kept in a securer place/way and one you use to sign all your commits. It makes sense to use a personal git signing key for signing commits and, especially in bigger projects, have the release/tag signing key separated and shared among the project lead/some trusted people, who are authorized to make releases. This way users also don't have to have 50 keys of your developers in their key store, but just the one of your project. Especially as users likely won't recognize all your developers and may not be able to verify whether this if a real developer of your's or an attacker.

So if you can  sign git tags. It already helps very much for distributing your software securely to your users. Signing git commits may also be useful, but is likely not as important as signing git tags.


Why would a stranger offer to write content for a nonexistent blog? I get emails like this all the time:

Hello dear,

I’m a long time reader. I’m writing to you because I’d love to contribute a guest post on your website.

I’ve been brainstorming some topics that I think your readers would get a ton of value from:

[The Best XXXL Extra Large Electric Heating Pad on Amazon for Full Body]

I’ll make sure the piece overflows with information that can’t be found anywhere else. Looking forward to your reply.

Have a nice day,

Lekin

It's from an ordinary looking hotmail account, and AFAICT contains just this text. There are no links to click, so it's not an ordinary phishing email.

If they really thought I'd like to include their content on my blog, if I had one, surely they know a spammy Amazon product name would be a turnoff.

So it feels like there's some other agenda here, but I can't figure out what it would be.

So it feels like there's some other agenda here, but I can't figure out what it would be.

Nope, it's exactly what it looks like. It's marginally-targeted spam. The sender is a scummy SEO marketer, and is hoping that you will allow them to write a (garbage) "blog post" for your site, filled with backlinks to their content.

  If they really thought I'd like to include their content on my blog, if I had one, surely they know a spammy Amazon product name would be a turnoff.

The sender is just really, really bad at making their emails sound convincing. I've seen much better written attempts than this.


Instrumentation vs virtual machine introspection I cannot differentiate between Instrumentation and Virtual machine introspection. Since the goal of Virtual Machine introspection is to examine the properties of a target through virtual machine monitor then what is the purpose and use of instrumentation technique.

The terminology is slippery and not completely stabilized; however, we can say that, usually, "code instrumentation" relates to modifications of some target code so that monitoring tools (or other kind of automatic management tools) can be applied on it; this does not necessarily involve a virtual machine. With a virtual machine, on the other hand, the code to inspect and monitor is unmodified and unaware of the fact that it is monitored.

For instance, if you compile C code with GCC, you can "profile" it (performance monitoring at the granularity of individual functions) with the -pg command-line flag: this flag instructs GCC to add extra instructions in the binary which record function entry and exit, for each function. This is instrumentation. It does not need any kind of virtual machine.

To make a metaphor, virtual machine introspection is like a zoologist crouched on a rocky hilltop, with powerful binoculars, observing from afar a lion stalking a herd of zebras. Instrumentation is more like the lion being sedated, strapped on an examination table, and the zoologist forcing an endoscope in its throat. Not the same activity, not the same goals, not the same kind of harvested data; and instrumentation is a bit more "invasive".


Can video feed be used to track location of an IP? I don't know if it is possible, but I have read that while a user is viewing a video, the location of user can be traced without sharing its knowledge to the user. Even when user has disabled the option to allow tracking for websites.
Is it possible? If yes how?

The streaming server needs to know where to send the video to, thus it is aware of your IP address.

Using this IP address, your estimated position can be requested from a so-called geolocation database (which connects networks to locations). This usually is not accurate to street or house level, but most of the time at least resolves the city and country you're in.

You can only prevent this using a proxy or VPN server, so your actual IP address is hidden behind it (and you will be located around wherever the proxy is located physically).


What specific information is used to verify an SSL certificate? When a CA's SSL certificate is stored in a browser, a server which presents a certificate signed by this CA can be verified by the browser. My question is: How exactly is this verification done?

I know that the certificate presented by the server to the browser contains information such as the server's public key and identifying information of the server (such as server name, location, etc).

But for the browser to prove that this information is correct, it needs a second copy of the same information to compare with and determine if there is a match or not. I know that the server's name is part of the URL, so the browser can get the value in the URL and compare with the information in the certificate. But what about the other information in the certificate? How is it verified when there is no second copy to compare with?

Subject identification in SSL/TLS server certificate is DNS name(s) usually and/or IP address(es) rarely, which are matched against the requested URL. Neither of these determines location. EV certificates must contain some physical location information verified by the CA, and other certs may, which the browser cannot further check; some browsers display some EV info, which the user could check against his/her knowledge of the organization/person that should be running the website.

The validity period is compared to the current time. If a client device has a wrong clock, or none, it can be tricked by a server using an expired cert for a stolen or broken key.

BasicConstraints, KeyUsage and ExtendedKeyUsage extensions if present (and at least the first two should be) are checked to make sure the cert is suitable for the SSL/TLS protocol in general and for the negotiated key exchange. Policies if present could be checked against configuration (or user entry) what policies are required, acceptable, or prohibited, but I don't think anyone does.

The Issuer name, and AuthorityKeyIdentifier (AKI) extension if present, are used to obtain (select) the parent CA public key used to verify the cert, so if they are wrong, the signature cannot be and is not verified.  This repeats up the chain and validity, BC, KU, EKU are also checked up the chain to make sure each cert is suitable to be an issuer (CA).

All certs (including chain) must also be checked for revocation. This is done using information outside the cert(s), namely a CRL signed by the CA, or an OCSP response signed by the CA or other trusted party. Nowadays OCSP responses are usually included in the SSL/TLS handshake by the server (called stapling); if not the browser can fetch them using the cert(s) CRL Distribution Point and/or Authority Information Access extensions. This can provide an indirect check; if you get valid (signed) data from CRLDP and/or AIA.ocsp it establishes those values are right, but if you have trouble communicating it doesn't necessarily mean they're wrong, and if you don't even try (because of stapling) then obviously you don't know at all.

The Public Key in the cert cannot be directly checked; the main point of PKI is for the relier (browser) to securely obtain the public key which it does not already have. The SSL/TLS handshake does confirm that the server has (and uses) the private key corresponding to the public key in the cert; the cryptographic mechanism for this varies depending on the key exchange negotiated.


Why are DSA keys referred to as DSS keys when used with SSH? When I generate a DSA key with ssh-keygen -t dsa, the resulting public key will begin with ssh-dss.

How come? Why not ssh-dsa?

DSS is simply a document that describes the signing procedure and specifies certain standards. The original document is FIPS 186 and latest revision in 2013 is FIPS 186-4. DSS is a standard for digital signing.

DSA is a cryptographic algorithm that generates keys, signs data, and verifies signatures. DSA, in itself, can use any hash function for its internal "cryptomagic", and it can also use any (L, N) for its parameters' length. DSS, as a standard, defines DSA's optional specifications.

DSS says that DSA should use SHA-1 as its hash function (recently, SHA-2). DSS says that DSA should use specific length pairs such as (2048,224), (3072,256), etc.

When SSH says DSS, they mean that they're implementing DSA in compliance with the DSS.


Considering majoring in "information security and network engineering". Will this course leave me between two different career paths? I am interested in majoring in something related to cybersecurity, so I read about it and looked up the college programs near me. The only course that I found relating to it in Jordan (my home country) is ISNE.

Here is the courses in the program: (pages 5 to 7 are the ones that really matter)

I read that there is a difference between information security and network security and this left me confused whether or not these are two different career paths. Is it like mechatronics, Which is kind of a mix between electrical and mechanical engineering and some stuff? Can anyone who is knowledgeable clear my doubts and guide me to how I could further educate myself about the topic?

The short answer is 'no', it is not a malformed degree. The curriculum is very broad to give you a broad foundation in the IT and cybersecurity field.

To say "cybersecurity" is like saying "medicine"; there are so many branches and specialities under that one word.

So you will not be between career paths, but you will not have a clear career path, either. In other college programs that look like this, the idea is to give you a little bit of knowledge in a lot of different areas so that you can choose what you want to study.


What's an easy way to perform a man-in-the-middle attack on SSL? I'd like to perform a man-in-the-middle attack on SSL connections between clients and a server.

Assuming the following:

I've got a certificate that the client will accept, via poor cert validation or other means.
I know the IP address of the server I'm trying to impersonate, and I'm in a position on the network to do things like ARP spoofing.
The underlying protocol could be anything, from HTTP to custom / proprietary stuff.

I could write some code to listen on a port, serve up the certificate and initiate SSL, then forward stuff on as a transparent proxy, then do some ARP spoofing to redirect traffic to me, but that's a lot of effort and becomes cumbersome when working on a test that has a tight time constraint.

What's a quick / easy way to perform a man-in-the-middle attack? Are there any tools designed to facilitate this in a simple way, without lots of configuration? Something that's actively being maintained is a plus.

Updated:

For HTTP you can use Burp Suite's proxy (Java), or mitmproxy.
tcpcatcher is a more general Java-based GUI capture and modify proxy which might be closer to your requirements, it includes content decoding and modification (manual and programmatic). It's HTTP biased, but accepts any TCP. It has SSL support, though the only drawback seems to be there's no (documented) way to use your own specific certificate, only on-the-fly ones. You could easily use one of the options below to work around that.
ettercap includes features for ARP, ICMP (redirect), DNS and DHCP "interventions", and supports direct SSL MITM (though not currently via GUI, you need to tinker with the conf and/or command line). This seems to be the best all-in-one for most purposes.
sslsplit is another useful CLI tool, it's (mostly) for intercept and log, not modification. It's quicker to get started with than ettercap and has features like SNI inspection, dynamic certificate generation, support for *BSD and Linux FW/NAT, and OCSP/HPKP/SPDY countermeasures for HTTPS. You still have to get the traffic to it though.

If you want quick, low tech and protocol agnostic, you can get most of the way there with just OpenSSL on a unix box:

mkfifo request response
openssl s_server -quiet -no_ssl2 -cipher AES128-SHA \
  -accept 443 -cert fake.crt -key fake.key  < response | tee -a request
openssl s_client -quiet -connect www.server.com:443 < request  | tee -a response

-quiet also enables -ign_eof which suppresses special handling of characters at the start of the line (for line-buffered input), like "Q" for quit. s_client also supports basic STARTTLS capabilities: SMTP, POP3, IMAP, FTP (auth), XMPP and TELNET (from OpenSSL-1.1).

Start each openssl in a different terminal. Replace the tee's with something scripted to modify requests and replies if needed. It's not the most robust, but it might be useful. It supports DTLS, should you require that, IPv6 support requires OpenSSL-1.1. (GnuTLS supports IPv6, and since v3.0 has DTLS support too, you can almost certainly do something similar with gnutls-serv and gnutls-cli, I haven't yet tried this though.)

ncat with its -exec option should work too:

ncat --ssl --ssl-cert fake.crt --ssl-key fake.key \
  --sh-exec "openssl s_client -quiet -connect www.server.com:443" \
  -kl 127.0.0.1 4443

You can just use "--exec" and wrap up your own client in a script instead. With s_client it helps performance a lot to pre-create a session file, then add -sess_in ssl.sess -sess_out ssl.sess to your invocations.

Again, if you need to script/code the MITM yourself socat is another good (and probably the most robust) option:

CERT="cert=test.crt,key=test.key,verify=0"
SSL="cipher=AES128-SHA,method=TLSv1"
socat \
  OPENSSL-LISTEN:4443,bind=127.0.0.1,reuseaddr,$CERT,$SSL,fork  \
  EXEC:mitm.sh

With a one-liner like openssl s_client -quiet -connect www.server.com:443 in mitm.sh to start with, works just like an inetd client.

stunnel is more proxy-like than socat, it has one big advantage that I don't see anywhere else: it supports in-protocol TLS upgrades/STARTTLS, for POP3, IMAP, SMTP and a few others in client and server modes; though LDAP and FTP are notable omissions (the latter understandably). Its inetd mode can be (ab)used just as with the "exec" options above.

For modifying generic text-based common internet protocols using these methods you might be able to get away with some sed (like a more connection friendly netsed) or light expect scripting.

The multi-protocol proxy Delegate also supports external (inetd-like) handling, and integrated scripting support for matching, filtering and rewriting for a subset of the supported protocols.

The only other things I can think of close to generic protocol agnostic MITM proxies are fuzzing tools, like proxyfuzz, or multi-protocol modular ones like backfuzz (be careful searching for that last one ;-).

Other possibly useful tools (for misdirecting traffic) include:

dsniff , including arpspoof
another arpspoof this version with IPv6 support
arpsend from vzctl
dnschef DNS proxy/server (Python)

I also came across references to Zorp several times while rummaging through my notes, non-free available in both a commercial (I have no affiliation) and a GPL version. Worth a mention, due to its claims of being a modular, extensible (by way of Python) multi-protocol firewall/gateway. TLS inspection is supported in the GPL version (SSH and others seem limited to the non-GPL version).


Is signature based malware detection a thing of the past? I made an experimental AV application to detect some test files as malware.  It uses a simple signature based detection to detect those files. When my test AV encounters a file, it computes the SHA256 hash of that file, and then compares it with a database of hashes that are "deemed" malware. It will then either quarantine or delete that detected file...
I realized that this method was very naive  and will never offer any protection against zero day attacks or detect viruses  whose hashes are not in the database.
Also, professional AV software use sandboxing and API hooking to detect suspicious activity of executables.
But consider this hypothetical case:

  If I have the MD5 or SHA256 hashes of all known viruses till date in this world, will using only signature based detection give protection to my user.

In this age of self replicating viruses is signature based malware detection still used by Anti malware software to detect computer viruses or does it have some other applications when dealing with malware?
What if the OS in which an Antivirus Software runs on does not give permission for API hooking or the system  does not have enough resources (RAM) for sandboxing, then will signature based detection have some application ?

Signature Based Malware is still the dominant mechanism used.

Heuristic mechanisms do exist and are very useful in limited circumstances, but are subject to too many false positives for more general use.

What has happened in the AV industry across the board is an application of "Big Data". It's no longer a case of just checking against a database of known bad signatures. Most AV vendors, including Microsoft, will check the hash of all executables. That hash check can have three main results:

Known Bad (Isolate,  Done!)
Know Good (continue, Done!)
Unknown  (Scan for virus signatures)

A. Signature Found (Isolate,  Done!)

B. Send a copy to the AV Vendor for Analysis

The immediate enhancement over your example test AV is the incorporation of Known Good hashes.

The less obvious but very powerful enhancement is the Big Data factor. When the AV company is doing this all over the world against billions of files, the chances of any given individual encountering a new 0-day drops dramatically, although it does still happen.

If you make your own executable, malicious or not, the third case will kick in. Microsoft, or most other large AV Vendors, will pull a copy of your executable and send it to their analysis teams. Here they will use heuristics during analysis and depending upon complexity, it will be fairly quickly entered into the worldwide database of executables.