How to select the correct Exploit and payload? (msfconsole) I am trying to learn about security and penetration testing. So far I've learned how to work with Metasploit (MSFconsole) and nmap (db_nmap).

I am using 2 VMs, one with Kali and the second with Debian server.

After running nmap on the server I got these results:

So, I tried to find an exploit for these services, without result. I searched in the auxiliary/scanner folder and also in the exploit folder and found nothing. I searched CVEdetails for these exposed HTTP services and I found this.

There exist many exploits for the HTTP service, So my questions are:

How can I exploit this service, How should I select the specific exploit and payload to use?
How do you recommend continuing the penetration test?

Well, the server you're scanning, is it a package made to contain known vulnerabilities? Because looking at the versions of the services, I don't see anything vulnerable standing out... The fact that you have a lot of vulnerabilities for apache http does not mean that the particular version of apache httpd that you have there is vulnerable.

A good place to check what vulnerabilities exist for a specific version of an application is https://www.cvedetails.com.

Edit: The cvedetails link shows a number of low-risk vulnerabilities, none of which are proven to provide arbitrary code execution.


Not hashing email registration confirmation link I sent emails out that contains an email registration confirmation link:

http://example.com?create=email%3Djay%40gmail.com%26confirm_key%3D53e321f97c145

I do not hash the link above. Before I sent an email containing this link, the user registered as a new member. Email address is inserted as a new record in the database together with a confirm_key.

So in my database there are two fields that are first filled up email and confirm_key. The confirm_key is generated by the PHP function uniqid().

My question is, what are the security risk in using this method, if any?

The only issue is that you're leaking information, in this case, the user's email address.  Since it's plaintext in the querystring, it's going to be stored by any logging that's occurring anywhere between the client and your server, potentially in bookmarks if the user bookmarks that page, if the URL is copied and stored or sent to anyone, etc.

I'll additionally point out that anything you do is going to be vulnerable to sniffing, since you're using HTTP rather than HTTPS.


CVE-2017-7494 Samba remote call. How do I know if Samba is running or not on my Ubuntu server? My servers are Ubuntu. I want to know whether Samba is installed accidentally or not. Is the following command correct?

It seems that Samba isn't installed.

$ samba --version
The program 'samba' is currently not installed. You can install it by typing:

$ ps -ef | grep smb
(empty)

I feel that the other answers, while undoubtedly useful, do not answer exactly what you asked for... that is, whether Samba is running, but either whether Samba was installed at some time (by looking at files on disk, which might be left over) or whether Samba is installed with the system's knowledge, which might not be always the case.

dpkg will not tell you whether Samba is installed; it will tell you whether it was installed using dpkg/apt or not. If you install Samba from scratch via a tarball, for example, the whole Ubuntu installation system will truthfully tell you that it's not aware of Samba ever having been installed... even if Samba is up and running.

To verify that samba is installed you do indeed try to run it:

smbd -V

If installed (even if it is not running), it will report its version.

The same check can be done with the client part of the Samba suite, which is not necessarily installed with the server:

smbclient --version

For the file system support, just in case, you do mount.cifs -V instead. Strictly speaking this is CIFS support, not Samba.

To know whether the Samba program is running, you can either check the running processes of the Samba suite (smbd, nmbd, winbind):

sudo ps waux | grep "[sn]mbd"

This will return either nothing if the program is not running, or a list of the processes part of the Samba suite:

root     23942  0.0  0.3 299100 15176 ?        Ss   May24   0:00 /usr/sbin/smbd -D
root     23943  0.0  0.1 298532  4744 ?        S    May24   0:00 /usr/sbin/smbd -D
root     23944  0.0  0.1 298556  7408 ?        S    May24   0:00 /usr/sbin/smbd -D
root     23946  0.0  0.2 299092  9504 ?        S    May24   0:00 /usr/sbin/smbd -D

Or you can verify whether they're listening to ports:

sudo netstat -nap | grep "[sn]mbd"

This will return nothing if the processes are not running, or it will tell you which ports are they listening to:

tcp        0      0 192.168.2.200:445       0.0.0.0:*               LISTEN      23942/smbd
tcp        0      0 192.168.2.200:139       0.0.0.0:*               LISTEN      23942/smbd

Above, for example, my smbd is listening on ALL (0.0.0.0) remote addresses.

Another way is to check whether anything is listening in Samba's place on TCP ports 139 and 445:

sudo fuser -n tcp 139

This will return either nothing (program not running) or the PID of the running process:

139/tcp:             23942


Should I invest my time in making my site HTTPS-only? I'm building a Django website that does not need to have registration/authentication.

The only sensitive part is a form with a reCaptcha v2. Of course I'm embedding the CSRF token, which then I read with Javascript and send it with Ajax requests.

Is HTTPS needed in this case? I'm somewhat confused, since as far as I know the token can be used only once.

Is HTTPS needed in this case?

In every case that I can think of HTTPS is beneficial.

The trivial case is if you don't have sessions, why would you need a secure connection if there are no sessions and everything is public? Having a secure connection actually helps your Google PageRank, and it also helps the user feel more secure by visiting your site

If you actually have sessions and dynamic content the benefits are of course more substantial.

One easy way to implement SSL/TLS certificates is using CloudFlare or some similar service.


Is DHCP spoofing ever possible on VMware? So I've just watched this Defcon video:https://www.youtube.com/watch?v=RaA5dEIqzzQ&t=1583s.
Apparently they were able to set up a rouge DHCP server and get a 50/50 chance of sending the victim the DHCP offer before the legitimate DHCP server. However, when I tried this in vmware, my success rate was down to a 0%. The default legitimate DHCP server from the NAT config of Vmware always responds to the client first before my rouge DHCP. This makes me wonder if it is just the setup of VMware that allows the default DHCP server to respond immediately. If that is the case, how do you get a rouge DHCP to respond faster in a virtual environment since there is no concept of "physical distance"?

Short answer is no, you can't.

If your vm network adapter is NAT, your rogue DHCP server is only on natted network. To test if machines from your host's network are taking ip from your rogue DHCP server, your vm's network should be bridge.

With your current configuration using NAT on your vm, you are going to be able to get ip from your rogue DHCP only from other devices/hosts inside that network and being different than a vm created on same Vmware host. This is because is Vmware is who manages it so its own DHCP is going to have priority always... so you can't get ip from other vm even "natted" created on the same Vmware host.

To get an ip from your vm rogue DHCP you must create some kind of special environment. For example:

If you create a vm on your NAT network which has already a Vmware and inside you create a vm with bridge network mode... that vm inside the vm for sure can take ip from your rogue DHCP with 50% of possibilities.


Is there a way to secure an API key on iOS? When a user logs in the App, they are given a unique API key (each user's API key will be different). The user uses this API key to make HTTP requests. Currently, the API key is saved in an SQLite database on iOS and it is retrieved from the database when you make API requests. However, I'm not sure how safe this is. On the backend, the user and backend team have the ability to delete the API key and we are using SSL.

I've thought about keychains, but I was told it doesn't really protect much.

https://stackoverflow.com/questions/14778429/secure-keys-in-ios-app-scenario-is-it-safe/14865695#14865695

The answer you linked, from 2013, is out of date. You can have secure enclave-backed Keychain private keys now. See Apple's article on how to store private keys in Keychain.

You will have to re-architect your API to use a public key scheme, but there is no way around this, since any fixed API key will require the key to be in memory at some point anyway.


About SQL Injection Mysql I'm trying to test SQL injection on a site (PHP, uses MySQL Database). When I put an apostrophe in the username field and leave the password box blank, after submitting, the form reloads and the fields become empty again. But when I used an apostrophe in the password field, the message says "Invalid Username/password".

What does that indicate? And if I put admin' as username (don't add comments) and in the password field, write ;Drop Table users; (don't add comment) are my comments gonna work?

Not enough information to tell - given this, it could simply be rejecting empty passwords, and taking any input in the password field, hashing it, then checking it against the DB safely.

Consider the following pseudocode (this is not intended to be good practice, just clear to read - do not use in production!):

if (isempty($password)) {
  reloadPage();
} else {
  $query = "SELECT * FROM users where username = :username";
  if ($user = dbquery($query, $username)){
    if (checkpassword($password, $user.password)){
      login();
    } else {
      reloadPage("Invalid Username/Password");
    }
  } else {
    reloadPage("Invalid Username/Password");
  }
}

This would give the described behaviour, without (assuming that the dbquery function makes a clear distinction between query data and user supplied parameters) allowing SQLi.

In a slight aside, using DROP TABLE in a penetration test is unlikely to go down well with the client. You should use safer methods to verify the potential flaw: get the current DB user, for example.


How secure is the web-based file browser that comes with my NAS? I have a Buffalo Linkstation Pro 2 Duo for home use. It has a web GUI for browsing the contents of the NAS (distinct from the admin interface). The idea is that you would expose the web GUI to the outside world and you could share files on the public internet. Internally the NAS is using some kind of LAMP flavor, I think.

What concerns me, though, is that Buffalo hasn't published an update in months (ever?). This would seem to tell me that Apache and all the other software on the NAS is very out-of-date.

Practically, would it be a very bad idea to leave the web GUI open to the outside world? Would the NAS be vulnerable to some kind of exploit? What about for a business?

This is a great question and I think your reasoning is sound: Regular updates generally mean the software will have a better security posture. The flip side of that coin is that software that doesn't get regular updates is either perfect (not possible) or neglected. The later is much more likely. So your instincts are working :)

The reputation of the company or open source project providing the software in question is a big factor here as well. This is especially true if the software in question is proprietary as you'll have to trust that the provider knows what they're doing and has good security practices (which includes pushing out regular updates). A quick web search can help you here as you can search for known vulnerabilities in the software you're using.

Use caution though: just because vulnerabilities aren't publicly known doesn't mean there aren't any. This is often just a good indication that the product isn't widely used and that no one is attacking it and publishing their results. What you really want here is a history of vulnerabilities being disclosed and the product being updated in a timely manor (quickly).

Also be sure you know what interfaces you're exposing to the Internet. NAS boxes always support web UIs like you mention but they also have tons of interfaces for 'native' integration with Windows/OSX/Linux systems like CFIS, NFS etc. Exposing interfaces like these to the Internet has different implications ... like NFS having NO built-in authentication!

So to answer your question directly: I'd strongly discourage you from exposing the web UI of a home NAS device like the one you mention to the Internet. I would liken this to exposing the management interface on a server (like ILO / IPMI interfaces) to the Internet and recent history has shown that just a bit of poking can uncover a ton of problems in popular IPMI implementations: http://threatpost.com/ipmi-protocol-bmc-vulnerabilities-expose-thousands-of-servers-to-attack

As always you should balance the risks you're taking in proportion to the data you're protecting. If you don't have anything sensitive on this device and it all gets backed up elsewhere then the implications of a compromise are lower. You can just wipe it and restore if you need to (that is if you even notice that it's been compromised). On the other hand if you're putting sensitive data on this thing (business, personally identifiable information etc) then a compromise will be more damaging to you or your business.

In this situation, IMHO, the "right thing" to do is to set up a good VPN and require all access to the NAS go through the VPN. You can do this with an industrial strength VPN or something as simple as an SSH tunnel and proxy. Personally I do the later and it's sufficient for my needs but YMMV.

Hope this helps!


Can attackers be traced if they used public WiFi I always thought it's possible to track attackers unless they try to hide their identities using some form of "physical" disguise. No matter how many proxies you use even TOR seems to be traceable by NSA but what about public WiFi networks?

Anybody can simply go buy a used laptop from Sunday market (MAC cant be traced), sit next to McDonald's and fire their scripts? How is it possible to counter such simple but efficient arrangement?

Every user leaves a lot of traces independent of their IP address. If you access web sites they store cookies, do browser fingerprinting etc. If you move from network to network the IP changes, but the computer specific properties stay. If they really want detect you, they will attack you with malware (drive-by-download) so that even anonymized access with TOR will not help, see http://www.wired.com/2013/09/freedom-hosting-fbi/.


What is the best way to protect an encryption key? I am using few secret keys to encrypt sensible date. What is the best way/place to protect the keys ? In a file located on my server ? Within the SGBG databse itself ? Or ... ?

You must store keys in such a way to minimize risks of the key being exposed to unauthorized third parties, while still allowing efficient operation by systems which must use the key. If such a system (your "server") comes under hostile control, then you have lost anyway. So the question about where the key should be stored really makes sense only with regards to partial breaches, in which an attacker gains some access to a part of the server, not to the whole thing.

That's about the most that can be said generally. Context matters.

If your context is about some sort of Web server, powered by some programmatic framework (say, PHP) with a SQL database for data storage, then we may argue that a very common kind of partial breach is SQL injection, which primarily allows the attacker to get read-only (or read-write) access to (parts of) the database, without directly impacting the security of the server itself. In that sense, the database may be said to be "more exposed" than the rest of the server; correspondingly, the keys should not be stored in the database itself. However, remember that this is only a very generic assertion which does necessarily apply to your specific case. Context matters.

Still generically, we may state that if your operating system offers some facilities dedicated to the storage of secret values, then using them is probably a good idea. In a Windows system, this points to DPAPI. Whether it will actually help is unclear (it, again, depends on the context -- the context matters) but it should not make harm.


How can log poisoning be successful with a Local File Inclusion attack? I just read a paper about Local File Inclusion on exploit-db.com, it can be found here. One technique with LFI is log poisoning as you may know already. You do an HTTP GET request that contains PHP code. Since it's not a correct HTTP request it gets logged in the apache error.log. Now the attacker can execute the PHP code within the error.log by doing something like http://victim.com/include.php?file=../../../../var/log/apache2/error.log. Now what I don't understand is thefollowing: logs by default are not world readable, so www-data who owns the apache2 process is not able to read error.log and so cannot execute the code within it! How can a log poisoning attack be successful then??

Perfectly legal and smart attack.

You're question really boils down to "how does this work when logs are by default not readable by the webserver?".

The fact is that many webservers are set up with custom log directories where the access control is not necessary enforced. This happesn more often than you would think. In some cases the access control for the log files is wide open because sysadmin needed some other system to read them, and he just opened it up for all processes.

This can also be used to execute code from other log files like from the SSH auth log. More on this here: http://lanmaster53.com/2011/05/local-file-inclusion-to-remote-command-execution-using-ssh/

Basically it boils down to wrong permissions on the files. Even so its a good attack which is very relevant.


How to secure yourself against jQuery preventDefault phishing? This is bugging me for a while now due to the potential security risk it involves.

Basicly by accident I discovered that this code is perfectly valid and works without a problem:

jQuery:

$(document).ready(function(){
    $("#phishingURL").on("click",function(e){
        e.preventDefault();

        window.location = "https://www.stackoverflow.com";
    });
});

HTML:

https://www.google.com

Most normal PC users just hover a URL to check if it actually directs towards the website they're expecting. In this type of phishing, you get to see the url you expect, yet you're still redirected to a different website. Ofcourse you can always check the address bar etc. But as I work a lot with older people, I know they're going to fall for this. So is there any way to protect yourself against this besides changing your habits?

Edit: Technically it's possible to use Flash on the pshishing site itself and change the browser address bar with SWFAddress.setValue(), making it even possible to make the address bar appear as if it's on the right website.

If this code exists on a website, it would be one of two reasons:

The website itself is malicious (or has been compromised by a malicious person).
There is an XSS flaw on a website, and an attacker has injected that script. (Or an external resource has been compromised to the same effect.)

Disregarding any client machine/network compromises.

Other than that, this code cannot run on a website other than itself. The Same Origin Policy would prevent the code from altering (say) an Iframe to change destination links like so.

A legitimate website doing this on purpose would fall into category (1) IMO.

The only place this would be an issue would be inside an email message viewed via a web-based system when a user wishes to verify links. However, scripts should not be allowed to run inside HTML email messages. Most good providers prevent this from happening by stripping disallowed content and implementing a Content Security Policy.

  So is there any way to protect yourself against this besides changing your habits?

Use a browser based password manager. This should only allow you to fill out credentials on a URL match. If a phisher sends you elsewhere, the password manager won't give you the option to fill out the login form so the user will realise that something is amiss.

  Edit: Technically it's possible to use Flash on the phishing site
  itself and change the browser address bar with SWFAddress.setValue(),
  making it even possible to make the address bar appear as if it's on
  the right website.

This only changes the URL's hash value, which is a client interpreted only section of the URL. This cannot change the domain or path in the address bar.


Are passwords longer than 128 bits useless if hashed with MD5? Are passwords that are longer than 128 bits useless if they get hashed/transmitted with MD5?

MD5 always uses 128 bits, thus someone would rather try to bruteforce the MD5-hash than the password itself or a password longer than 128 bits would create collisions that create the same MD5 of a password shorter than 128 bits.

Am I missing something?

First, using a simple MD5 hash to protect a password is a bad idea from start. See How to securely hash passwords? for details.

Apart from that, you assume that a 128-bit password would have the same strength as the 128-bit MD5. This implicitly assumes that the 128 bits of the password are chosen randomly. This is usually not the case, i.e. passwords are commonly chosen to be memorable and memorizing 32-byte random data (or about 42  ASCII characters when encoded with base64) is not easily done.

By asking if passwords longer than 128 bits are useless since MD5 is only 128-bit you also assume that there is a 1:1 mapping between a 128-bit input and its 128-bit MD5 hash. I don't think that this is a property of MD5, i.e. you would need in some case (slightly) more than 128-bit input to generate a specific MD5 value.

But assuming that the password was actually 128 bit randomly chosen data, that the attacker has no access to the password but to the MD5 hash of it and  that this MD5 hash is then used to validate the password - in this case the attacker would need to do a pre-image attack, i.e. find an input which matches the existing hash value. It turns out that this is actually slightly less complex than brute-forcing all possible passwords. According to Pre-image attack on MD5 hash from crypto.se the complexity to find an preimage is about 2123 which is slightly less complex than brute forcing everything ( 2128 for a full search, i.e. 2127 on average) but still not easily doable.


Privilege escalation if the privileged ID is known If I know the ID of a group, whose privilege is higher than mine, is it possible for me to execute programs using that group ID? If so, how do I do it? If not, why not?

Will appreciate all answers.

Not if the system has been designed properly. For example, Linux groups have IDs which are sequential, so there may be groups with IDs going from 500 to 510. That doesn't mean you can just become a member of one of those groups though. If you could, so could anyone who guesses at other group IDs, which would render the security of the system worthless.

It would be possible that a bug in the system implementation resulted in users being able to join arbitrary groups, but any such bug would hopefully be fixed quickly, so while it's not impossible as a concept, practically, it shouldn't happen.


Does excluding username letters from passwords increase security? Recently I was asked to change a password, along with a password policy which reqires you to use a digit, a special character and a letter, but forbids any letter from you log in name to be used for the password, does this increase security? To my eyes, it shrinkens the set of available characters and therefore increases the probability of a possible match in a brute force attack. Am I right, or do I miss something?

If this is a default (as I was told) it will be publicly known that this application expects passwords to fulfill this restriction.

Anything that restricts the set of possible passwords makes it more vulnerable to a brute force attack. The only reason to forbid some passwords is if the restriction to the password space is compensated by the high propensity of users to pick passwords that can be easily guessed.

Let's say you would like passwords with at least 38 bits of entropy (that's already very high for a password that can only be attacked online under normal circumstances). That requires a password space of at least 274877906944.

Forbidding passwords that are too short is reasonable. Assuming the character set is restricted to the 94 ASCII non-space printable characters, 6 random characters are the minimum (689869781056). Forbidding shorter (≤5 characters) passwords barely makes a difference: there are only 7417954634 of them — the passwords of length 5 or length only make up 1.1% (a little over 1/94) of the passwords of length up to 6. And because users rarely pick completely random sequences of characters, it makes sense to have an even higher minimum length. A minimum length barely makes a dent in the password space, because it grows exponentially.

Forbidding a character, conversely, makes more and more of a difference as passwords get longer. Let's say you pick a password with 8 random letters and a random digit at the end (and don't rely on the punctuation character for entropy). That gives 2088270645760 possibilities — over 241, meeting the 38-bit requirement. If you forbid as little as one letter, the password space shrinks to 1525878906250 — that's 27% of the password space wasted right there. With 6 forbidden letters, the password space shrinks to 256000000000 which is less than 238.

Random letters are hard to memorize, so there are better methods to generate longer but more usable good passwords. corrEct horSE battEry StapLE? Nope, I can't use that. Let's take the popular Diceware list of 7776 English words and memorable letter and digit sequences. 3 random items on the list satisfy the 38 bits requirement (77763 = 470184984576). But 3 random items that don't contain any letters of my username? Only 2130 items fit the bill, leading to 9663597000 possible passwords, only 33 bits. Still decent, but less than our target. And the Diceware list has an annoyingly high number of special characters if you're going to type that password on a mobile device. I have a list of 4172 short, common English words, and can pick 3 random words to get 37 bits of entropy, which with an added digit gives the required 38 bits (726160964480 possible passwords). If I exclude letters in my username, that drops to 787 words, for only 29 bits with no digit or 33 bits with a digit.

Forbidding common characters for users who deliberately pick good passwords is bad, and I've bored you with the math to show it. What about the users that password restrictions really target — the 99% who don't pick randomly?

Girlfriend's name? No. Mother's maiden name? No. Hometown? No. Damn, this is difficult, the restriction must be working! paSSword1? Swordfish1? qwErtyuiop1? Ah, zxcvbn1 works for me, how lucky.


Hashing a hard drive before shutdown Problem: Currently have no way to verify integrity of my offline encrypted system. I would like to ensure the system hasn't been physically tampered with while I've been away from it.

(To clarify:while I am aware that the system cannot be modified without gaining access to the my encryption key. This question is to address the off-chance that the encryption is somehow bypassed. i.e. They gain access to my encryption key.)

Proposed solution: Hash the contents of the hard drive and have that hash added to a thumbdrive that I will maintain control of.

Question:

How difficult would it be to obtain a hash for a harddrive before every system shutdown and have that hash added to a log on a thumbdrive that can be validated after every login?
Would I need to have the system unmounted to ensure this method is valid?
Is there already a prepackaged solution that you are aware of for this problem?

Considerations:

I would need to ensure physical security of the thumbdrive to make sure the checksums match is valid (maintaining physical security of a keydrive is much easier than carrying a computer around with me)
This method would probably be more easily implemented on virtual machines (though that doesn't do anything if the host is compromised).
Having a Live Linux USB on the thumbdrive to create the hash on the unmounted drive may be a more simplistic method, although not quite as streamlined.

Other thoughts:
I am aware that system encryption offers some level of integrity assurance. But in the off chance that encryption becomes violated, I would like to know.

OS: Arch Linux

Near impossible, or at least very difficult.  First, there is too much data.  It would take a VERY long time to compute a hash of the entire HDD every shutdown and again for every boot.  You could alternately use chaining of hashes though to get around that, but it would require a specialized file system.  Second however, even if you were willing to wait for a full hash or use a file system that does chaining like that, values are going to change during the boot process itself.  Temp files will be created, paging files will change, etc, so it won't work on a system drive without a specialized boot loader on the USB stick that could validate from the earliest stages.

Either way, the hash is irrelevant if the encryption key is securely maintained.  You can't meaningfully change encrypted data if you don't have the encryption key.  You can corrupt it, but a basic parity check would find that kind of tampering.  If the encryption key becomes compromised, you are screwed either way as your data could be read without altering the drive.

An elaborate attacker could also do something like loading in to firmware or memory before your hash can run and then replacing itself after your check, thus avoiding detection by this means (and altering the hash after the first time) unless you do some really elaborate custom mounting that will process everything from the HDD as untrusted and only load things which pass validation chaining.

It also is a lot easier if you are mounting it as an offline drive mounted after boot and can trust the hardware you are connecting to it since that doesn't require a trusted bootloader then.  If you can't trust the hardware, bios and other system firmwares also become a concern.

Not much is out there to try to handle this situation as just about every threat model considers the system broken if the key is compromised.


Sulley - Logic behind primitives Are sulley's primitives used to build a description of the protocol or to specify what kind of data we want to generate?

Let's take for instance the following primitive s_string("ok", encoding="ascii")

In the first case, it would mean, the protocol expects ascii strings, so I would expect sulley to generate ascii strings as well as non-ascii strings.

In the second case, it would mean, sulley must only generate ascii strings.
Which one is correct?

Thanks.

From the Sulley manual,  it is the

Encoding to use for string

I think that's your second case.


SQLMap, SQLiPy and connection I can successfully perform a sqlmap scan of my target from a host. However, if I run sqlmapapi from that same host and use SQLiPy from Burp, sqlmapapi returns connection errors.

The specific SQLiPy errors retrieved are:

INFO: 16:55:43 - testing connection to the target URL
CRITICAL: 16:55:44 - page not found (404)
WARNING: 16:55:44 - HTTP error codes detected during run:
404 (Not Found) - 1 times

The successful sqlmap scan is using the same command generated by SQLiPy.

I have also confirmed connectivity/DNS etc to the target.

So what is the difference between the manual command and the SQLiPy initiated command via sqlmapapi?

I have added an update to SQLiPy that will hopefully be incorporated into the BApp store soon that allows the user to toggle the HTTP method/verb.  If you don't want to wait on the update in the BApp store, you can get it at https://github.com/codewatchorg/sqlipy.  The latest version is 0.5.2.


Any good tutorials / libaries for implementing TLS-SRP? In this thread, Tom Ptacek explains what Password-Authenticated Key Exchanges are, and it got me really interested in them. If I'd like to start learning about how to build them into real world software communication protocols, where can I find a starting point for information on understanding and implementing TLS-SRP? I'm ideally looking for a hierarchically-structured tutorial that couples the understanding with the implementing, but I'd appreciate any quality materials you can provide.

As with most crypto stuff you shouldn't implement it yourself but use a well-known library instead.

OpenSSL has SRP-support since version 1.0.1. An example is contained in ssl/ssltest.c and there is also a file crypto/srp/srptest.c.

GnuTLS seems to support SRP since over a decade and the implementation has been constantly improved. Examples can be found under doc/examples/ex-client-srp.c and doc/examples/ex-serv-srp.c.


How does LSA authentication on Windows work? I'm trying to understand the security protocols on Windows from a high level as part of legal research into cybercrime, and I'm having difficulty figuring out where to focus my research.

I've already gone down the LSA authentication model path, because that is what the Flame virus used (somehow) to get itself access to services. At least according to this security firm. However, and I know I'm missing something, it looks like programs can just grant themselves access to the system.

I read through this post on Live ID, and Windows Authentication, but that's not what I'm interested.

Kerberos seems solely concerned with interactions between different boxes. Similarly, NTLM doesn't seem concerned with local activity on the computer. Which brings me back to LSA authentication.

I know that I'm missing some steps here, because it looks like you can just call LsaLogonUser(), and assuming you have the credentials (do you have to steal these?), do whatever you want. I found this image from this article, but to be honest, I'm only vaguely sure of what I'm looking at:

That diagram is very accurate for XP and previous. The reason it is so complicated is the several levels of abstraction involved.

There are two primary (as in, "most used") ways of logging into Windows - as a standalone workstation user, and as a member of a domain. In both cases, on XP those credentials pass through the LSA client and its server.

At the backend, then, LSA must determine "who to ask" to determine if the credentials are indeed valid. That's where the "negotiate" block comes in - which will do one of two things:

If the system is configured as a workstation, use the NTLM scheme as configured on the box and talk to the SAM database.
If the system is configured as part of a domain, talk to the server to see what it supports, and give it what it needs.

In essence, this process isn't all that different from negotiating what sort of hashing to use for say a HTTP authentication method: the server says what it wants (PLAIN, DIGEST, MD5) and I send the password as needed.

There is an allusion to other credential types fitting in here in the form of "msgina.dll". This is the component responsible for talking to the user after Ctrl+Alt+Delete and can be replaced to provide new UI such as fingerprint and smart card logon. In each of these cases, LSA must still talk to the backend database (whereever that is) to get an authentication token of some form.

You can also add extra authentication protocols to LSA via LSA providers. This is the corresponding "talk to the authentication database to determine if this is a valid user" component and you can read about these components here and directions for how to write one here.

Now, once this process is complete, the user is handed an authentication token called an access token. UAC aside, presenting this token is how processes indicate to the system they are already authorised to act on behalf of the user.

This is what is going on and how LSA and the various components fit together.

Now, part two of my answer. Flame targeted LSA for two reasons:

It is estensible. You can register new authentication protocols, new GINA/Credential Providers (XP/Vista+ respectively).
It runs on boot of the system, with NT AUTHORITY\SYSTEM privileges.

This makes it a marvellously good place from which to launch your malware and remain persistent on the system. See this analysis

As you can imagine, there are checks and balances preventing any old program from installing itself there and even being run there, by means of Authenticode. However, Flame used a stolen certificate to bypass this, which is where things got interesting. The information, specifically the Common Name, contained in the authenticode certificate is displayed as part of the authenticode warning dialog. So in this case, the malware would actually appear to be authored by "Microsoft Corporation". Once they click OK and run Flame with elevated privileges, it then has all the access it wants. It can then register itself as an LSA provider and will then be run automatically each time the system starts.


Possible to read strength of encryption? With the recent talks of governments trying to weaken encryption, I had a question about how they would implement it.

For example, let's just say that the government banned anything above AES-128. I know AES-128 is still "uncrackable" at this point in time, but for the sake of argument let's say that's what they decided to do.

Is it possible for someone in the middle of an encrypted channel to tell the size/strength of encryption used? So basically, would the government be able to tell you are using too strong of encryption just by recording the data sent between two endpoints?

Thanks

Is it possible for someone in the middle of an encrypted channel to tell the size/strength of encryption used?

In a well-designed algorithm, encrypted data should be indistinguishable from random noise. Some formats normally have header fields. e.g., PGP in asymmetric mode will tell you what the intended asymmetric key id is and the intended symmetric algorithm will be encrypted with that key. I'm unsure what header is output in symmetric mode. Zip files will specify algorithm and bit size clearly in the header. 0x66(0E|0F|10) map to AES(128|192|256). The spec does allow setting the field to 0xFFFF for "unknown algorithm".

Thus, the answer is entirely implementation dependent. Without specifying a header, it should be impossible to determine algorithm and bit length without decrypting the contents through brute force.


How do packers/crypters deal with ASLR? If a packer or crypter is used to obfuscate a piece of executable code, it seems that calls and references made in that code will not be updated at load-time and will be incorrect when the code is unpacked or unencrypted! How does a packer or crypter deal with this problem?

Modern packers will handle this in the same way as the Windows PE loader: by implementing relocations.

The .reloc section in a PE file (documentation here) holds details about which addresses need to be “fixed up” if the image cannot be loaded at the preferred address. This is referenced in the standard PE header.

A packer can read this data and implement relocations. How the packer handles this will be implementation specific. Perhaps it will store the original relocations somewhere in the packed executable, or store them in a custom format.

It is also possible to strip relocations, leaving a PE file that is not ASLR aware, as if it were never compiled with /DYNAMICBASE. A packer could choose to do this instead of implementing relocations.

There is a question about UPX on StackOverflow and a common fix during analysis is to simply disable ASLR (reference 1 / reference 2).

You can read a lot more details in this ReverseEngineering.SE post about the layout in the PE section.


MITM attack on WPA-PSK using fake AP: Can the password be intercepted from normal Windows AP-logon mechanism? I have already tested how to do a MITM attack, using a fake AP to intercept the WPA-PSK, by presenting the user to a vendor (e.g. Linksys) logon page, before routing network traffic through eth0.

However, for someone with computer expertice this will probably not work.

Instead of presenting the user with a fake logon page in the browser, is it then possible to intercept the passphrase from the Windows logon mechanism (seen below)? To be more specific, is it possible to configure the fake access point to fool Windows into requiring a passphrase (in the fashion below) and send it unencrypted to the AP? This would seem legitimate from the users point-of-view!

Normally, the AP created by airbase-ng is open and does not require logon credentials.

For your example (WPA2-Personal), the answer is no, not without bruteforcing it. At least not as long as Windows adheres and continues to adhere to the official standard. Presenting a fake login page like you did is AFAIK the only way to try to get the password, but this may indeed trigger some warnings as it is not standard behaviour.

However, with WPA2-Enterprise, you might be lucky in two cases:

a vulnerable EAP implementation is chosen  (e.g. lightweight EAP is considered very insecure, EAP-MSCHAPv2 is also broken). The general recommendation nowadays is to use EAP-TLS or PEAP-MSCHAPV2.
EAP-TLS is chosen, but the supplicant does not validate the server's certificate (or you can forge the real certificate). By extension, PEAP-MSCHAPv2 will also be 'broken' in this case.


Can I have a virus/adware in my router? When I browse the Internet (in any browser), there are extra ads. I thought it could be on my computer, tried Ubuntu live disk, and even there were these ads. Same ads are on my iOS and Android devices too. I did a hard reset on my mobile devices, but that didn't help either.

I think these ads come from either my ISP or my router. Can I have a virus in my router? How can I check it? Are there any other possible variants?

You could check your DNS Settings on your router and may reset it or change it to an Open one (Google, OpenDNS,..).

  Then you also need to prevent the attack from happening again.
  Measures to do that include:

  performing a factory reset to clear any settings left by the    attackers
  installing the latest router firmware
  using a strong password on the configuration interface
  limit access to the configuration interface to appropriate places    (wired, local connections, not the internet)
  log out of the configuration interface after use (and do not tick    'save password' on your browser when configuring the router)
  changing the IP addresses used and supplied by the router (for    example change from 192.168.1.1 to 192.168.123.1)

posted by @James Snell

You can find some more information here: How to get rid of an Ad bot?


Is there any way to discover why Windows Smartscreen is flagging your download? Since Windows Smartscreen is now marking downloaded files signed with SHA1 post 1/1/16 as potentially unsafe, we have had to get a new code-signing cert. With it being a new cert, it has no 'reputation' with Smartscreen, and our new builds are still being marked as potentially unsafe.

Is there any way to get more helpful information from Smartscreen to find out exactly WHY a particular download has been flagged? We would like to be sure that it is 'just' the code signing key's low reputation before we push it out to customers.

The best starting point would be to investigate its logs and see if it gets you anywhere. By default, SmartScreen does not log events as per Microsoft's documentation:

  Logging: By default, SmartScreen Filter does not log events. However, if you use the Application Compatibility Toolkit to enable logging for application compatibility events, SmartScreen Filter logs an event when a warning is shown for a website.

Here is the link to Microsoft Application Compatibility Toolkit 5.0


Threat modeling: why would a https remote endpoint be prone to privilege escalation? I'm currently creating a threat model for a web application and have a http proxy at the edge of the trusted network. It's communicating with Google Maps via the API, using a https connection; so this connection is crossing a trust border. I'm using Microsoft's free SDL threat modeling tool in the 2016 version. After modeling the entities I checked what possible attack surfaces it generates.

One of those threats I do not understand. It says "An attacker may pass data into HTTP proxy in order to change to flow of program execution". What is this refering to? This proxy only accepts http(s) requests and forwards them for a client and does the same with the answers from outside (gateway setup). The only possible explanation I could think of would be a vulnerability in the proxy software/OS, e.g. an overflow exploited by manipulated http(d) packets or headers. Are there any possible other explanations I am missing?

Of course this threat generation is generic and treats my http proxy only as a "generic process" so it might not be applicable at all and is only referring to a threat existing if two processes are communicating on the same machine (or by RPC) and not over a network interface.

Thanks and regards

If someone compromises the proxy, they can attack your web app.

If they're on the same machine (inside all the same boundaries) then this matters less, not more.  But the proxy is probably more exposed to attack.


Tools to scan for PII I'm looking for well known tools that will scan for any PII within a network. For example, I would like to be able to use a plug and play method, meaning I drive to a client, plug my laptop in, and scan for all sensitive material, such as SSN, Account numbers, medical records, etc. I believe I'm looking for a "portable" DLP system. Currently, I have come across, Find_SSN, Sensitive Number Finder (SENF), Spider, Identity Finder. Any thoughts? In addition, I've read about FTK toolkit and EnCase, but not quite sure if they would perform the way I'm hoping them to. Essentially, I would like these tools to perform similar to any VA tool, such as Nessus, LANguard, OpenVAS, etc., but scan for PII.

Try http://code.google.com/p/opendlp/

  OpenDLP is a free and open source, agent- and agentless-based, centrally-managed, massively distributable data loss prevention tool released under the GPL. Given appropriate Windows, UNIX, MySQL, or MSSQL credentials, OpenDLP can simultaneously identify sensitive data at rest on hundreds or thousands of Microsoft Windows systems, UNIX systems, MySQL databases, or MSSQL databases from a centralized web application. OpenDLP has two components:


Unregister your device from a WiFi network Recently, I connected my Android device to an open wi-fi network. Then a web page opened up asking me to choose username and password to log in with. Now when I connect the same device to that network, the web page doesn't open up anymore and the phone automatically logs into with the chosen credentials.
Is there a way to make the network believe that my phone has never connected to it before, so that I can log in using different credentials?

The wifi access point is probably recognizing your android device's MAC address, which normally remains constant, even throughout power-cycles.
If you want the wifi access point to 'believe you are a new user', you may be able to temporarily change your MAC address.  See https://www.techjunkie.com/change-mac-address-android/ for more info.


DTLS vs direct use of AES. What are the threats unique for direct use of AES instead of DTLS? For regular traffic in mesh network (between Internet of Thing devices) customer decided to use one of two options:

DTLS PSK ciphersuite - DTLS based on pre-shared symmetric key
or direct use of AES - customer wants to minimize traffic between sleepy devices (battery should be alive for several months)

Questions:

What are the additional threats of second option (AES) that do not exist for first option (DTLS-PSK)?
How to mitigate these threats (say using AES in CBC or another mode and change IV, etc)? Not reinventing DTLS protocol manually and not with the same overheads as DTLS has.

There is mandatory requirement to share symmetric key between IoT devices within mesh network for regular traffic. This key fits for both options. (First joining of new device will use DTLS-PAKE - I mentioned this just in case - this is not important for this question).
Let's specify DTLS-PSK mode more exactly  - I'm going to use mbedTLS crypto library with define MBEDTLS_TLS_PSK_WITH_AES_128_CCM_8 is specified in cipher suite. Where CCM is mode for block ciphers that provides both authentication and confidentiality.

[D]TLS provides quite a bit of protection beyond just confidentiality (encryption). It verifies the server identity (authentication), protects against message corruption or tampering (integrity), prevents replay attacks, and can provide forward secrecy (no ability for an attacker to decrypt a recorded message even if all persistent keys later become known to the attacker). Modern versions also include protections against weaknesses around not-widely-understood areas of cryptography such as padding.
There are several forms of [D]TLS-PSK, but all of them potentially reduce the security somewhat. If you're not using asymmetric keys at all then any node in the network can impersonate any other node, so you lose strong authentication. The simplest form of PSK also does not provide forward secrecy, though it is possible to use ephemeral DH key exchange (enabling FS) with symmetric keys as well.
However, [D]TLS-PSK is still almost certainly more secure than any hand-rolled system. (The saying around cryptography "don't roll your own" applies to cryptosystems - at least, whenever possible - not just to primitives.) Trying to build your own cryptosystem on top of AES (or any other primitive) means you must consider stuff like padding oracles, IV/nonce generation, length, and rotation, integrity protection, replay prevention, and so on. Using an well-reviewed protocol with a well-reviewed implementation avoids all these concerns.


Is the video/audio traffic from WebRTC TURN relay servers encrypted end-to-end? As with the applications Signal and Jitsi Meet Today I found a video on YouTube that surprised me (https://www.youtube.com/watch?v=Pkc3sE6iKV4). It is by Rob Braxman, a privacy advocate with a lot of expertise.
He talks about all kinds of video conferencing situations. Like one-to-one, one-to-many and many-to-many.
It is quite obvious that one-to-many and many-to-many uses a central server as a relay server and therefore no end-to-end encryption is possible.
However, he also says that WebRTC TURN servers (which are used in unfortunate Internet situations such as NAT, firewalls, etc.) cannot provide end-to-end encryption because the server must capture and relay the video blocks. Only encryption during transmission is possible, so that anyone who controls the server can watch the traffic.
I thought the TURN relay servers just forward the encrypted data.
The interested part of the video begins around 20min.

I have not seen the video but I believe you are  mistaken/ misunderstanding something.
Those services use a Selective Forwarding Unit (SFU).
The turn server is only used for traversing double nat-ed connections.
The SFU combines the incoming streams and re-encrypts them for transport (this is not E2E but is Encrypted at transit)
The turn servers just pass back and forth the different packages the receive from the differing participants.
A good Turn server runs I. Encrypted mode so it’s a plain TLS connection. Even without the turn server can only leak the meta data about the connection not the details of the packets themselves (they stay encrypted).
The SFU on the other hand does work on the decrypted data streams, it comes into affect with Jitsi meet when there more than 2 parties involved. They have done some test with E2E encrypted SFU’s but that added the complexity of key management and performance was also affected.


Security measures to take upon acquiring a new laptop? I'm planning on buying a regular HP laptop. However, I'm still a novice when it comes to information security. I'm planning on using this laptop to SOLELY login to my bank accounts and NO OTHER website, via my school's secured WiFi connection. What steps would you take to secure an ordinary mid-range performance laptop to a maximum level? I know there are are plenty of resources on the internet that can help me get started and this may seem too broad of a question, but I'd really enjoy the insight.

Despite your already accepting an answer, I'll add mine.

Most importantly, us two factor authentication (2FA) with your bank!

You need not dedicate a laptop to your banking. If you are worried about the laptop, use a bootable non-persistent OS, there are dozens of Linux variants or you could even use Windows-to-Go if you want Windows. This will bypass everything on your laptop drives that might be there.

FDE is nice for many reasons, but for banking purposes you only need to protect your bank information. This can be done strictly in your head or in an encrypted folder on a thumb drive.

The operating system you use is completely irrelevant.

Forget Tor and VPN's for banking purposes. Most banks blacklist Tor nodes even if you wanted to use them. You have no interest in hiding your identity, quite the reverse in fact.


If using a different password for every application is considered good practice, why is using a directory so widespread? The title pretty much sums it all. We are always told that we should use a different password for every site and application, so that if one of those accounts is compromised, the others will still be safe.

Why is it then that using a directory, especially in enterprise environments, is considered normal practice and is also recommended?

I understand the obvious convenience of centralized user management, but isn't this clashing with the multiple passwords rule after all?

It is true that if your password is compromised, your access to all other systems in the directory goes with it. However, there are other differences that make the practise of password reuse a completely different ball game:

Directory: Once the breach has been reported, the account can be disabled or the password changed from a central location.
Separate applications: The account would need to be disabled or the password changed per application.
Directory: The breach will not be spread out over systems controlled by different entities - You would just usually need to contact your sysadmin.
Separate applications: You would need to contact potentially hundreds of different companies in order to regain control of your accounts with potential for accounts to be missed.
Directory: Any password guessing attacks over different systems in the directory would most likely to be detected.
Separate applications: If it is known that you possibly use the same password over different accounts, then an attacker could split their attack and try different word lists against different systems undetected until they gain entry.


Security "Threat" with Picture of Yourself? This is one issue which I have came by in the world of Security, which I can not seamlessly wrap my head around. How is it a threat to one's security by showing them a picture of themselves to people online?

On a lot of games which I play, from League of Legends to Habbo Hotel, if people find an actual picture of someone who is has an ego out of the ass, they see it as a security threat to themselves and their well being.

I do understand a part of it, but that does with psychology and philosophy, but where does this play into security of using the internet?

Maybe I am misunderstanding security overall here? Or a picture of myself over the internet is going to cause me some issues down the road with my security of my online profiles, such as here on StackExchange?

Not sure how that long story relates to uploading a picture online.

The big dangers of your picture being online, is

the image has metadata that you don't want to leak (e.g., your phone geotags your location, so if some crazy person sees it they could figure out where you live), or
the image helps people from real life identify you and helps average users tie your semi-anonymous online behavior to yourself (could be problematic), or
the image posted online helps connect you to illegal/unethical activity (e.g., bank robber posts selfies with illegal machine gun used in recent robberies, or
the same image is used by you in multiple locations, easily found by using an image search tool like tineye, which loses your privacy.

For example, I probably wouldn't be able to identify you by your tiny gravatar thumbnail.  But if I examine the image URL: https://www.gravatar.com/avatar/6151310f6b2443a98ee2b0987ab01b7d?s=128&d=identicon&r=PG and change the size of the image to say 1024:

https://www.gravatar.com/avatar/6151310f6b2443a98ee2b0987ab01b7d?s=1024&d=identicon&r=PG

I could probably identify you.


Is it possible to execute a php script in an image file? I have an image upload php website. Users can upload images to my website. A user claims he can hack my website using an uploaded image.

I opened all the images that he uploaded to my server with notepad. The last line of one image is:

Àpa@ ;
<?php

echo "test ok";
?>

Can he hack my website using this image? How do I prevent users from uploading images like this?

Yes, your server could run PHP code within an image file if it is not configured correctly:

http://www.phpclasses.org/blog/post/67-PHP-security-exploit-with-GIF-images.html

An example from that is image.gif.php. A file can be be both a valid image and a valid PHP script, it's not sufficient to simply check image size or other properties. Nor is it sufficient to strip metadata, an uncompressed GIF can contain PHP as image data (though it may be unpretty), PNG supports arbitrary data chunks.

The flaw is accepting uploads with insufficient sanity checking, specifically attempting to prevent unwanted filenames (e.g .php) by using a non-anchored regex like \.(png|gif|jpg|jpeg) (no $ anchor), and allowing those images to be served from a directory with PHP processing enabled. Best practise is that you should probably never use a user provided filename as-is.

These are fairly classic data validation and input validation failures.

If you follow the PHP installation instructions (for Apache 2) you'll have something like this in your Apache config:

<FilesMatch "\.ph(p[2-6]?|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>

Note the $ anchor, it will prevent file.php.gif from being interpreted by PHP.
(What's missing from those instructions is making sure that PHP is limited by a <Directory> context containing only trusted code, and not writeable by the web server user.)

If you don't follow those instructions, and use mod_mime's AddType (or AddHandler) instead:

AddType application/x-httpd-php .php      # STOP!

This can cause the same problem because mod_mime may do something you don't expect with multiple extensions. See http://blog.dynom.nl/archives/Be-careful-with-double-extensions_20081024_25.html (thanks to Hendrik Brummermann for pointing this out). This risk can be mitigated with correctly configured <Directory> context to allow only trusted code.

This document (PDF) is a little old, but it covers the mitigations well:
http://www.net-security.org/dl/articles/php-file-upload.pdf

Another possible source of problems is insecure include/require statements (also covered in that PDF) which allow an attacker to include uploaded content by altering query strings or HTTP request headers.

See also the recent related question: Risks of a PHP image upload form
(though I do not think it is correct to rely on getimagesize to verify images), and
Use PHP to check uploaded image file for malware? (which contains a useful set of links).


Regarding SQL Inject me Firefox add-on? Using SQL Inject Me Firefox add-on,I have selected the check-boxes then click on Execute button of SQL Inject Me tool.

After getting result, it has displayed following responses

Server Status Code: 302 Moved Temporarily
Tested value: 1 UNI/**/ON SELECT ALL FROM WHERE
Server Status Code: 302 Moved Temporarily
Tested value: ' OR username IS NOT NULL OR username = '
Server Status Code: 302 Moved Temporarily
Tested value: %31%27%20%4F%52%20%27%31%27%3D%27%31
Server Status Code: 302 Moved Temporarily
Tested value: 1 UNION ALL SELECT 1,2,3,4,5,6,name FROM sysObjects WHERE xtype = 'U' --
Server Status Code: 302 Moved Temporarily
Tested value: 1'1
Server Status Code: 302 Moved Temporarily
Tested value: 1 AND ASCII(LOWER(SUBSTRING((SELECT TOP 1 name FROM sysobjects WHERE xtype='U'), 1, 1))) > 116
Server Status Code: 302 Moved Temporarily
Tested value: 1' AND non_existant_table = '1
Server Status Code: 302 Moved Temporarily
Tested value: 1 AND USER_NAME() = 'dbo'
Server Status Code: 302 Moved Temporarily
Tested value: 1' AND 1=(SELECT COUNT(*) FROM tablenames); --
Server Status Code: 302 Moved Temporarily
Tested value: '; DESC users; --
Server Status Code: 302 Moved Temporarily
Tested value: 1'1
Server Status Code: 302 Moved Temporarily
Tested value: 1' OR '1'='1

Please find attached image.

I want to know what is exactly 302 moved temporarily?

Is my site is vulnerable?

While I haven't used SQL Inject Me plugin before, it is hard to tell if you are vulnerable or not by the data and screenshot you shared.

The 302 Moved Temporarily is a HTTP response. It means that the webserver wants to send you to a different page. If this HTTP response was sent to your Firefox it would lead to Firefox loading a different page, such as the index or whatever.


Creating an application in which all user content is encrypted Does any one have references or sources on how to approach developing a web application in which the content is encrypted and unreadable for the developers or company owners; I'm referring to content such as legal docs, in which there is a need to keep information confidential for third parties.

The protected data should be the content say of Word docs, some metadata such as author (Lawyer), involved parties and maybe trial type would be searchable and not encrypted but the details and content of the document will be.

It would be visible/decrypt-able by the person (lawyer) who wrote it, by its associates if given permission and by the client (one of the parties in the document).

Ideally the metadata would be extracted and the the content encrypted for subsequent upload and storage

This depends entirely on what you need the application to do, exactly what data needs to be protected, and who is permitted to view the data.

In the simplest case, where your application is merely an indexing system for documents and the document metadata can be stored in the clear, you can use client-side encryption to protect the document itself: the encryption key never leaves the user's computer, so it's not possible for anyone else to read the document.

In the extreme, you'll need to look into homomorphic encryption.  This permits you to operate on encrypted data without knowing what that data is, but it's incredibly slow, and so cutting-edge that most of the security implications are currently unknown.

Your needs probably lie somewhere in between; you'll need to define your problem better before you can decide what solution to use.


What kind of damage controls should an online banking web application implement? Considering an online banking or paypal-type web application with

username/password login and
two factor authentication (2FA) for transactions

What are best practice security measures for damage control, assuming

username/password or
username/password and 2FA

have been compromised.

I can only think of transaction logs that allow understanding and reverting all malicious transactions made. What else is commonly used?

Most banking sites limit the amount of money transferred in a specific timeframe. You will not be able to perform transactions that have a greater value than say € 5000.00 in a single 24 hour period without prior notice to your bank.
This prevents/limits the most harmful cases of fraud.

Additionally all (at least all german banks) will use some sort of second factor per transaction that requires the users specific consent for every transaction.

A transaction log is always a good idea, and can be used as a valuable feature for your customers too.


Nikto commandline options I was reading from Nikto's site on the commandline options used and I am curious about this option

https://cirt.net/nikto2-docs/options.html

-ask
Whether to ask about submitting updates: yes (ask about each-- the default), no (don't ask, just send), auto (don't ask, just send).

May I know what is it sending and to where? If I don't use this option, what is the default behaviour of Nikto?

I am asking this from a Pentest point of view where we do not want to accidentally send sensitive customer data to third parties.

This option looks for version strings Nikto doesn't know about and sends them to cirt.net:

  If the outdated Nikto plugin sees a web server it doesn't know of, or a version that is later than that defined in db_outdated, then it will send this information back to cirt.net for inclusion in future versions of Nikto. Server specific information (e.g. IP addresses or hostnames) are not sent.

Nikto manual

While it says Nikto doesn't send specific information like hostnames to cirt.net, there is always the possibility of a mistake such as custom version strings which disclose information being sent. This feature can be disabled in the configuration file.


Windows system password hashed - see which hash is used How can I know / see if my windows is using NTML, LM, NTML2 for its user account passwords?

What is the standard today, in windows systems?

Currently windows uses NTLMv2 to store the password, but for backward compatibility some system uses LM hashes. Now it is recommended by the Microsoft to not to use LM method to store the password because of its weakness towards brute force attacks. If you want to see currently which method is used then you have to navigate to  HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\LSA. You will see the entry named NoLMhash with the DWORD value 1. It means LM hash storage is disabled in your system.

On the same location you can see the name LmCompatibilityLevel edit that and see the value associated with it and if the value is 0, 1 or 2 then force the system to use only NTLMv2 by changing that value to 3.

If you are in the LAN then you can check which method is used by your system to communicate to the servers by capturing the packet using any ethereal tool i.e tcpdump, wireshark in the network.

Refer this link to understand the compatibility


Yubikey with KeePass using challenge-response vs OATH-HOTP i got my YubiKey 4 today and first tried it to use KeePass with OATH-HOTP (OtpKeyProv plugin). My Configuration was 3 OTPs with look-ahead count = 0. It was not working that good because sometimes the OtpKeyProv plugin did not recognize my input when i pressed the button too fast. So i changed to 6 OTPs with look-ahead count = 12.
But with that it was not "that comfortable" anymore because i needed to press the button 6 times and had to wait a few seconds between the pressed to be sure the plugin recognizes the input.

So i tried the challenge-response method with the KeeChallenge Plugin. it just worked flawless. does anything speak against using the challenge-response method with the KeeChallenge Plugin or is it safe to use? i know the OtpKeyProv plugin is more secure but does that make that much of a difference?

depending how how the plugin does it internally this can be quite an intresting way of adding security.

essentially this thing misuses HOTP big time, by calculating the next however-many OTPs needed and forms them together with the master pass to encrypt the database.

but of course when you have lookahead active (and you really should, especially on a nano) it generates a few more sequences of keys in case you incresed the counter accidentially.

The idea behind it isnt bad, although obviously keepass needs to store the seed (shared secret) in the database to allow for re-encrypting it.

the keechallenge plugin works on the same premise: hashing a shared secret with some kind of challenge (the counter in HOTP), but this plugin is actually safer from a few standpoints.

1) it provides a 160 bit output of HMAC-SHA1 instead of "just" of log2(10^(6*x)) bits (x is the number of consecutive OTPs you select, 8 consecutive OTPs would you get just to 159 and a half bits of length)

Simply saying, you need to tap MUCH less for the same security Level, and while the OTP plugin could probably be configured to use a ton of OTPs for even higher security, with modifications the Challenge-Response plugin could also run multiple challenges throwing the number of bits through the roof, with again just an eighth of the needed taps (and no concern of mis-tapping and not getting the proper sequence).

2) as the challenge is provided from the database, we dont need to worry about accidentially touching the key or lookaheads, which means we dont need to lower the security by allowing multiple second factor solutions to get in.

Simply said number 2 means the Yubi only has the Secret and the DB has what could be called the "state" of the challenge, while in TOTP, the Yubi has both the state and the secret needed to decrypt the DB and the state changes everytime you touch the key, meaning you would need to account for multiple states.

although obviously the shared secret still needs to be stored in one way or another inside the database (unless you don't change the challenge at all, but that's reckless).


how to scan a web application that uses Captcha I have a web application I am doing a security assessment on and it uses captcha for both the login and for certain operations inside the app.  The interesting thing is that this particular app displays the text of the captcha right under it (users complained, so...), so it would be feasible to rig something up to read the captcha text and use that, enabling the scan to be automated.  Can anyone point to a resource that would help me script this?  I use IBM appscan and Burp Suite.

Without that text, though, I'm limited to hand testing.  Would it be fair to say that these captcha makes the app immediately more secure because it is resistant to automated scans?

In your question, you mention that the app displays the text of the captcha right under it. If you mean that the correct answer to the captcha challenge is displayed to the user as text in addition to its display in an image, then it should be a simple matter to script an automated scan. Your script would be able to complete the login process by reading the text of the captcha answer from the web page, and then providing that answer in the proper field.

I haven't used the tools you're using, so I'm not familiar with scripting capabilities that they might provide. But in Python, you could use urllib to implement this capability. In Perl, you could use LWP.

In my opinion, using a captcha can reduce some risks in a web application, especially risks related to a new-user enrollment process being abused by automated (non-human) clients. It could help as a part of a login form for existing users, but to a lesser extent. A well designed login form should protect itself from brute force login attempts, even wihthout a captcha (for instance, by limiting the number of failed login attempts possible in a given time period for the same user account or client IP address).

And of course, displaying the answer to a captcha challenge in text pretty much removes the usefulness of having a captcha to begin with. At that point, the implementation is inconveniencing the user while providing no security benefit.


Is it possible to test for Postgres BlindSQL injection using pg_sleep() in a WHERE clause? In mysql, I am familiar with using the following payloads to test for blindsql when the WHERE clause is vulnerable (all payload examples from fuzzdb):

1 or sleep(TIME)#
" or sleep(TIME)#
' or sleep(TIME)#

In postgres, my first instinct was to try the following:

1 or pg_sleep(TIME)--
" or pg_sleep(TIME)--
' or pg_sleep(TIME)--

Unfortunately, the postgres payloads don't work because pg_sleep() returns VOID and hence is disallowed in a boolean expression.

I have tried the following workarounds:

Casting pg_sleep() to some other data type (void -> bool type conversion is disallowed)
I have considered trying to create my own pg_sleep() function, but this doesn't work in the black box environment that I audit in..
ex: CREATE function pg_sleep(int) RETURNS int AS '/lib/libc.so.6', 'sleep' LANGUAGE 'C' STRICT

Any ideas?

I have tried looking in the docs for other functions that may be used in place of pg_sleep() that do not return void, but I have not had any luck.

First of all, try the simple approach. Is this really a situation which only allows a completely blind injection? For SQL injection vulnerability in the WHERE part it is far more common that the application will react differently depending on whether it got at least one row or none at all. And it is likely that the injection can force an empty result set via AND 1=0 or an none empty result set via OR 1=1

If this approach fails because the data is not used for anything visible or you cannot force the empty/non empty set, only then it is time to look for blind injection techniques.

To include a SELECT clause into an WHERE part you can use a sub select or a function like strpos:

strpos(
    (SELECT CASE WHEN 1=1
            THEN pg_sleep(10)
            ELSE pg_sleep(0) END
    )::text, '1'
) > 0;

There is an interesting paper on Advanced PostgreSQL SQL Injection and Filter Bypass Techniques.


Issues of using HOTP w/ iteration window I am using HOTP to generate OTP to validate a request, in order to prevent replay attacks. I'm thinking about using a window of 10 (or so) iterations to accommodate a possible mismatch in the counter of client and server, but i am a bit concerned about the way i should treat those iterations.
Should i reject every token that is less than the last confirmed counter? Or can i have a little margin there?

EDIT:

The reason for me to ask is because i am doing a "three party authentication", by this i mean the device owner authenticates itself by sending a token (with the HOTP in it) and another server will then use it to get something out of a resource server (a bit like oauth but...). So if the device owner authenticates 2 servers the counter will be 1567 and 1568, but if the second server (with the 1568 counter) gets to the resource server first, then the other one will be rejected

Thank you.

The "OT" in "HOTP" means "one-time". This is true only if the server indeed rejects passwords corresponding to a counter value which is not greater than the last confirmed value. Having "a little margin" here would mean accepting that a given password is accepted twice, the very thing that HOTP tries to prevent.

This is all based on the idea that the HOTP owner uses his passwords sequentially; there is never a situation where the owner would have any interest in using a password which is not the last one that his password-generating device produced. Correspondingly, if the server received at some point the password corresponding to counter value 1567, then the server knows that the owner's device has gone to value 1568, and any attempt at using, say, password 1565 would be a sure indication of foul play.

The "window" is toward the future, because the device owner may have inadvertently pushed on the button a few times without noticing it, so maybe the next password will correspond to counter value 1575, not 1568, and the server will still accept it.

In other words, the window behaviour as specified in RFC 4226 is the margin you need. There should be no need for any margin in the other direction; if there is such a need, then you are probably misusing HOTP badly.

Edit: if you have several servers consuming one-time passwords from the same source, then I strongly hope that you route all such passwords to a single authentication server, that maintains the counter value. (If this is not the case then you have much bigger issues.)

If you just fear that two such OTP may reach the authentication server "out of order" then you can indeed make things a bit looser without compromising security, but it requires some care. The important property of a one-time-passwords system is that each password value should ever be used once. The counter value, with the semantics explained in RFC 4226, is a cheap and efficient way to maintain these semantics: the server only has to remember the last seen counter, and that's all.

However, you can make the authentication server remember the actually used password values. This can be a "backward window": at any time, the server has a current counter N, which is the highest seen counter value, and remembers all see passwords in the N-9 to N range. With such a window, the server can receive passwords slightly out of order: a password will be accepted if its counter M is greater than N, or is in the N-9 to N range and was not seen yet. The programming on the server is slightly more complex, but not unsurpassingly so.

Important note: the "backward window" is safe in the case of HOTP, but that does not extend to just any "one-time password" scheme. This is safe for HOTP because HOTP is a MAC computed over a counter value -- it relies on the counter not to repeat itself, but not on the possible counter values being used in numerical order. The same would not be true for one-time password schemes which use hash chains (where each OTP is a hash of the next one). What I say here is only for HOTP.


Fastest public-key algorithm for testing purposes As part of an automated test suite I need to run a lot of gpg --encrypt and gpg --decrypt processes.

In order to make each invocation of gpg --encrypt and gpg --decrypt faster, I would like to use a very fast public key algorithm.

I understand that the fastest ciphers are also those providing the weakest security, especially at small key sizes. Security, however, is not important issue in this case: the passphrase-less key is even released publicly as part of the test suite.

For reference, this is what my GnuPG version supports:

Pubkey: RSA, ELG, DSA
Cipher: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128,
        CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

To recap, what is the fastest combination of algorithm and key length available in GnuPG?

That's going to vary from machine to machine and GPG binary to GPG binary; does the machine offer AES-NI instructions, does your GPG binary use them, is it using 64-bit operations, are XOP or AVX instructions available and used by your binary, etc.

There is only one answer: benchmark it on your particular setup!

Daniel Kahn Gillmor posted just such a benchmark script on the gnupg users list in 2010, including a SHA1 sum and a signature, naturally.

Note that output is from the Unix time command, formatted as + in seconds.

If you want something different, then modify the script!

#!/bin/sh

# Author: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
# Date: Tue, 28 Sep 2010 14:25:19 -0400

# This script produces some roughly-formatted OpenPGP performance data
# against different algorithms and keysizes

set -e

REPEAT=100
ASYM_ALGOS="RSA DSA"
KEY_SIZES="1024 2048 3072 4096"
DIGESTS="SHA1 SHA224 SHA256 SHA384 SHA512"
CIPHERS="3DES AES AES192 AES256"

if gpg --debug-quick-random --version >/dev/null 2>/dev/null ; then
    QUICKRANDOM=--debug-quick-random
elif gpg --quick-random --version >/dev/null 2>/dev/null ; then
    QUICKRANDOM=--quick-random
else
    printf "don't know how to set quick random number generation"
    exit 2
fi

encalgo() {
    if [ "$1" = "DSA" ]; then
    printf "ELG-E"
    else
    printf "%s" "$1"
    fi
}

describe_system() {
    # FIXME: this is fairly Linux-specific.  it'd be better to use
    # something more generic to get info about the CPU and RAM
    # available:
    cat /proc/cpuinfo 2>&1 || :
    free 2>&1 || :
    uname -a
    gpg --version
}

# quick key creation:
setup() {
    rm -f testmsg
    for rep in $(seq 1 25) ; do
    echo "this is a test message for benchmarking OpenPGP signature validation times." >> testmsg
    done
    for algo in $ASYM_ALGOS; do
    for size in $KEY_SIZES; do
        if [ "$algo" = "DSA" ] && [ "$size" -gt 3072 ]; then
        # gpg can't do DSA > 3072 bits
        continue
        fi
        mkdir -m 0700 -p ${algo}-${size}
        if printf 'Key-Type: %s
Key-Length: %s
Key-Usage: sign
Subkey-Type: %s
Subkey-Length: %s
Subkey-Usage: encrypt
Name-Real: OpenPGP Benchmark Key %s %s bits
Name-Comment: DO NOT USE!
' "$algo" "$size" $(encalgo "$algo") "$size" "$algo" "$size" | GNUPGHOME=${algo}-${size} gpg $QUICKRANDOM --batch --gen-key ; then
        for digest in $DIGESTS; do
            output=${algo}-${size}/testmsg.${algo}-${size}-${digest}.asc
            if ! GNUPGHOME=${algo}-${size} gpg --digest-algo "$digest" --clearsign < testmsg > ${output} ; then
            rm -f ${output}
            fi
        done

        for cipher in $CIPHERS; do
            output=${algo}-${size}/testmsg.${algo}-${size}-${cipher}.asc
            if ! GNUPGHOME=${algo}-${size} gpg --armor --cipher-algo "$cipher" --encrypt -r 'Benchmark' < testmsg > ${output} ; then
            rm -f ${output}
            fi
        done
        else
        rm -rf ${algo}-${size}
        fi
    done
    done
}

signing() {
    for algo in $ASYM_ALGOS ; do
    printf '%s Signing (x%d)\n' $algo $REPEAT
    for length in 'digest:' $KEY_SIZES; do
        if [ -d "${algo}-${length}" ] || [ "$length" = 'digest:' ]; then
        printf '%s\t' "$length"
        for digest in $DIGESTS; do
            if [ "$length" = 'digest:' ]; then
            printf '%s\t' "$digest"
            else
            for x in ${algo}-${length}/*; do
                cat < "$x" > /dev/null
            done
            targfile=${algo}-${length}/testmsg.${algo}-${length}-${digest}.asc
            if [ -e $targfile ]; then
                stats=$(bash -c "time -p for seq in $(seq 1 $REPEAT | tr '\n' ' '); do
GNUPGHOME=${algo}-${length} gpg --digest-algo $digest --sign >/dev/null 2>/dev/null < ./testmsg
done" 2>&1)
                printf '%s+%s\t' $(printf "%s" "$stats" | grep ^user | cut -f2 -d' ') $(printf "%s" "$stats" | grep ^sys | cut -f2 -d' ')
            else
                printf 'X\t'
            fi
            fi
        done
        printf '\n'
        fi
    done
    done
}

verifying() {
    for algo in $ASYM_ALGOS ; do
    printf '%s Verifying (x%d)\n' $algo $REPEAT
    for length in 'digest:' $KEY_SIZES; do
        if [ -d "${algo}-${length}" ] || [ "$length" = 'digest:' ]; then
        printf '%s\t' "$length"
        for digest in $DIGESTS; do
            if [ "$length" = 'digest:' ]; then
            printf '%s\t' "$digest"
            else
            for x in ${algo}-${length}/*; do
                cat < "$x" > /dev/null
            done
            targfile=${algo}-${length}/testmsg.${algo}-${length}-${digest}.asc
            if [ -e $targfile ]; then
                stats=$(bash -c "time -p for seq in $(seq 1 $REPEAT | tr '\n' ' '); do
GNUPGHOME=${algo}-${length} gpg --verify >/dev/null 2>/dev/null < $targfile
done" 2>&1)
                printf '%s+%s\t' $(printf "%s" "$stats" | grep ^user | cut -f2 -d' ') $(printf "%s" "$stats" | grep ^sys | cut -f2 -d' ')
            else
                printf 'X\t'
            fi
            fi
        done
        printf '\n'
        fi
    done
    done
}

encrypting() {
    for algo in $ASYM_ALGOS ; do
    printf '%s Encrypting (x%s)\n' $(encalgo "$algo") $REPEAT
    for length in 'cipher:' $KEY_SIZES; do
        if [ -d "${algo}-${length}" ] || [ "$length" = 'cipher:' ]; then
        printf '%s\t' "$length"
        for cipher in $CIPHERS; do
            if [ "$length" = 'cipher:' ]; then
            printf '%s\t' "$cipher"
            else
            for x in ${algo}-${length}/*; do
                cat < "$x" > /dev/null
            done
            targfile=${algo}-${length}/testmsg.${algo}-${length}-${cipher}.asc
            if [ -e $targfile ]; then
                stats=$(bash -c "time -p for seq in $(seq 1 $REPEAT | tr '\n' ' '); do
GNUPGHOME=${algo}-${length} gpg --cipher-algo $cipher --encrypt -r Benchmark >/dev/null 2>/dev/null < ./testmsg
done" 2>&1)
                printf '%s+%s\t' $(printf "%s" "$stats" | grep ^user | cut -f2 -d' ') $(printf "%s" "$stats" | grep ^sys | cut -f2 -d' ')
            else
                printf 'X\t'
            fi
            fi
        done
        printf '\n'
        fi
    done
    done
}

decrypting() {
    for algo in $ASYM_ALGOS ; do
    printf '%s Decrypting (x%s)\n' $(encalgo "$algo") $REPEAT
    for length in 'cipher:' $KEY_SIZES; do
        if [ -d "${algo}-${length}" ] || [ "$length" = 'cipher:' ]; then
        printf '%s\t' "$length"
        for cipher in $CIPHERS; do
            if [ "$length" = 'cipher:' ]; then
            printf '%s\t' "$cipher"
            else
            for x in ${algo}-${length}/*; do
                cat < "$x" > /dev/null
            done
            targfile=${algo}-${length}/testmsg.${algo}-${length}-${cipher}.asc
            if [ -e $targfile ]; then
                stats=$(bash -c "time -p for seq in $(seq 1 $REPEAT | tr '\n' ' '); do
GNUPGHOME=${algo}-${length} gpg --decrypt >/dev/null 2>/dev/null < $targfile
done" 2>&1)
                printf '%s+%s\t' $(printf "%s" "$stats" | grep ^user | cut -f2 -d' ') $(printf "%s" "$stats" | grep ^sys | cut -f2 -d' ')
            else
                printf 'X\t'
            fi
            fi
        done
        printf '\n'
        fi
    done
    done
}

run() {
    WORKDIR=$(mktemp -d "${TMPDIR:-/tmp}/openpgp-benchmark.XXXXXX")
    OUTPUT=$(mktemp "$(pwd)/openpgp-benchmark.$(date +%F_%T | tr ':' '-').XXXXXX")
    printf 'Working in %s...\n' "$WORKDIR"
    cd "$WORKDIR"
    ( describe_system
        setup
        signing
        verifying
        encrypting
        decrypting ) | tee "$OUTPUT"
    printf 'log written to %s...\nPlease mail back to Daniel Kahn Gillmor <dkg@fifthhorseman.net>.\n' "$OUTPUT"
}

action="$1"
if [ "x$action" = "x" ]; then
    action=run
fi

case "$action" in
    setup|describe_system|signing|verifying|encrypting|run)
        "$action"
        ;;
    *)
        echo "Usage: $0 [setup|describe_system|signing|verifying|encrypting|run]  " >&2
        exit 2
        ;;
esac


How can this web server be compromised? A linux server has Node.js installed with the http-server package. The server will respond to requests on port 80 with a file in the same directory named index.html.

An interesting characteristic of this server is that it exposes full read access to guest users via ssh. Any file on the system can be read by guests (except the SSL private key). Guest users can confirm that the SHA hashes of the node, http-server, and ssh binaries on the system match reference versions, and can confirm that those binaries are the currently running processes.

Is it possible for an attacker (via privilege escalation) or the owner of the server to modify the server in such a way that it serves a different version of index.html to specific IP addresses, while hiding this fact from any third party?

As long as you don't setup the server yourself you cannot be sure that what you are seeing with ssh is actually what is happening on the server. At the end your ssh access could just be a well built honeypot and nothing you see there relates to real server activity.

Even if you've setup the server yourself you cannot be sure, because there is still the BIOS, the firmware on the network cards, router in between client and server etc. All of these can affect what data get actually transferred to the client but all of these could be used to compromise the data.

And even if ssh shows the proper state of the server and no router, iptables or others are tampering with the server provided data: there might still be an in-memory malware like Darkleech affecting what actually gets served. You will not detect this when looking at the process table and you will not detect this when looking at the files, because it is just in the memory of the HTTP server.


Why do some online banking sites (and others who desire secure login pages) sometimes add autocomplete="off" on their login page input fields? For example: http://www.natwest.com/x-user.ashx?redirect=trusteer.interstitial.url&condition=trusteer.enabled2%3Dtrue

<input name="...." type="text" maxlength="10" id="ctl00_mainContent_LI5TABA_DBID_edit" autocomplete="off">

What are the security benefits of this, if any? Is it worth the sacrifice in usability?

The problem with autocomplete is that your browser stores information, which may be as sensitive as credit card info, and potentially anything stored in the browser could be grabbed by an attacker who compromises the browser.

Autocomplete="off" tells the browser it is not to store this information. Just a layer of safety which will require the user to type it in each time.


Performance of verifying the certification chain? I am writing an application where performance is important. I am using a technology called Named Data Networking, and the a point to note is that each data packet contains a signature of the sender.

Now, I would like to verify the data packet that I receive from Bob. I validate the certification chain until the authority, etc. Suppose that after a while, I receive another data packet from Bob. If I have cached the previous certificate (suppose that only I have access to the cache), when I receive another packet from Bob with the same signature as the cached certificate, can I be sure that the data packet is authentic? Or should I verify the chain again (this process is a bit expensive for my application)?

Yes you can make that assumption, at least for some time. Best would be to re-validate the signature every some many seconds/minutes/bytes depending on the use case.

If possible, try to create a packet chain. For example; every individual packet calculates an hash (take HMAC(K,m)) over the data m in the packet using key K which can be the the hash from the previous packet. This essentially links a chain of packets were a packet can only be valid if the previous packet was too. As an additional benefit, it does not only guarantee the authenticity but also the integrity of the data. Such a construction is way faster, but is not always possible. If packets are received in parallel or in random order this won't fly.


How to detect zip file encryption algorithm As we know zip files supports a simple password-based symmetric encryption system and some vendors use other algorithms. I used the zipinfo command in Linux but it doesn't say what encryption algorithm is used. How can I find that out?

7Zip archiver (freeware) has an info button that among other useful things tell you the encryption type an archive is using.

As a general note, .Zips usually use something called "ZipCrypto Deflatte".


What are some examples of managed language exploits and where can I learn more? I'm a software developer who mainly programs in C# and C. I'm currently studying to transition into InfoSec related development. Most learning resources on exploiting that I've found, both online and physical books, seem to focus on C and other non-managed code. However, managed code is not entirely safe from exploits, although it may be tougher/impossible to find a memory vulnerability.

What types of exploits/vulnerabilities in the language are out there that have caused damage to managed programs? I'm talking about technical exploits that a programmer can open up naively in the code or ones that are inherent to the language itself. This could apply to any managed language but I'm focusing on C# or Java here.

It's really important to keep in mind, that memory vulnerabilities are from the only issues out there.

I've found that it's the logic errors, which really bring a program to its knees. Several have lead me to successful DDoS or RCE. These occur in all languages, human error can easily and frequently be exploited.

Here is a list of some, in no particular order:

Improper input validation

Real-World-Example: Injection. Being part of the OWASP Top 10, it can be found anywhere, and in any language. Especially SQL injection and XSS stand out.

Uncatched exceptions

Real-World-Example: These more often that not lead to a DDoS. I once looked at a program using threads and locks. Too bad that I could reliably trigger an exception state just after the lock was acquired. Ouch.

Use of insecure functions

Real-World-Example: Many programming languages (especially scripted ones) offer some sort of real-time eval. The use of these is bad practices.
You know what else is bad practice? Rushing out an unfinished prototype as the actual product. Happens more often then you'd think. I know that these kind of relate to input validation, however it does not always need user input specifically to exploit these.

Pro-Tipp: My scripts grep for these functions before any assessment takes place. (Source known, obviously)

Dev- vs. Production Environment

Real-World-Example: A program which used sockets. In their development environment, each machine had 'unlimited' amount of available sockets.
The computers where the software was eventually deployed on didn't.
Their server could easily be crashed, and it was a critical piece of infrastructure as well.

Developer Misunderstanding or Lazyness

Real-World-Example: This one is my favorite by far! I once looked at web server, self-built in Python.
In Python, the inbuilt HTTP-Handler has a 'do_METHOD' function for every HTTP-method. If you want your own handler, you subclass it and overwrite these functions, which is exactly what they did. Now they had one function which was called 'do_WORK', that had nothing to do with serving HTTP at all.
Python (for forward-compatibility reasons, I can only assume) calls these functions by string-matching them. Which means that Python would actually try to call whatever function with the name of 'do_METHOD' (where method is the method stated by an HTTP-Client/Request) would be available. HTTP-method 'WORK' wasn't a thing...Until then. Therefore I could now call 'do_WORK' early and trigger a race condition. Beautiful.

These are just a few, but always remember: Computers do not make mistakes, humans do.


Do vendors put backdoors on network devices? There are several articles about "planting backdoors on network devices by vendors intentionally" , for example Hardware Vendor Offers Backdoor with Every Product.

They found backdoors that were made by the vendors. Also, they mentioned, that major network device companies put backdoors on devices to give support staff emergency access to devices. If they find a security vulnerability they want to be able to patch it easily without having to make the user download and install a fix.
Note that the backdoors I am considering is not the kind that Ed Snowden called a "government backdoors".

Are these backdoors real?
Are they necessary or do we need to patch it?
Is it also a potential danger?

Are these backdoors real?

Yes, these backdoors are real. A quick search for vendor backdoor provides some examples:

Hardware Vendor Offers Backdoor with Every Product - that's about Allied Telesis  you've already mentioned.
Backdoor account replaced by another backdoor in vendor stumble - about a vendor backdoor in audio equipment, where the fix was to replace the backdoor with a new one.
Equipment Maker Caught Installing Backdoor Account in Control System Code - RuggedCom had a vendor backdoor in their industry equipement where the password could be derived from the MAC address.

And these are only some examples of obvious vendor backdoors instead of accidentally left backdoors from debugging or similar.

  Are they necessary?

These are backdoors the customers don't know about, i.e. the vendor can sneak in and make changes without the customer noticing. I believe that having such backdoors greatly undermines the trust into the vendor. I don't think these are necessary - there are ways to have service accounts which are known to the customer and get only enabled for a short time if the customer actually requests support.

  Is it also a potential danger?

Of course, For example in the above example of RuggedCom the password could be simply derived from the MAC address and not only the vendor but also potential hackers had knowledge about it. This means it is no longer a vendor backdoor but a backdoor for hackers too.


Does domain resolve to CDN (Cloudfront) IP and not the actual web-app server? If a web-app is using cloudfront as CDN, what happens if I ping the domain? Am I pinging the cloudfront endpoint? Or the web-app server? Why is it DNS resolution resolves to different IPs in this case?
One example is when I ping the domain, I use the IP on shodan and see that it's a cloudfront hostname. I'm guessing this means I'm reaching the cloudfront endpoint and not the web-app?

If a web-app is using cloudfront as CDN, what happens if I ping the domain?

You are pinging CloudFront, not the domain. The DNS entry for the domain point to CloudFront, and CloudFront stays in the middle between you and the domain.
The name resolves to different IPs for load balancing. As CloudFront primarly is a cache (among other things), answering with different IP addresses means clients will connect to different cache endpoints and share the load.

this means I'm reaching the cloudfront endpoint and not the web-app?

Exact. You don't know the endpoint real IP, and hiding its own IP is one reason for someone to use CloudFront or any other CDN.