Tag: retrieve

C++

Retrieve the User-Agent HTTP

ObtainUserAgentString retrieves the User-Agent HTTP request header string that is currently being used. //.. #pragma comment (lib, "urlmon.lib") //.. char httpUseragent[512]; DWORD szhttpUserAgent = sizeof(httpUseragent); ObtainUserAgentString( 0, httpUseragent, &szhttpUserAgent ); printf("%sn", httpUseragent); //..//.. #pragma comment (lib, "urlmon.lib") //.. char httpUseragent[512]; DWORD szhttpUserAgent = sizeof(httpUseragent); ObtainUserAgentString( 0, httpUseragent, &szhttpUserAgent ); printf("%sn", httpUseragent); //..

DNS, Enumeration, Information Gathering, Reconnaissance

Retrieve MX records

nslookup is a command-line administrative tool for testing and troubleshooting DNS servers. The syntax for noninteractive mode is: nslookup [-option] [hostname] [server]nslookup [-option] [hostname] [server] Parameters Commands:   (identifiers are shown in uppercase, [] means optional)  NAME            – print info about the host/domain NAME using default                    server  NAME1 NAME2     – as above, but use NAME2 …

Microsoft SQL Server

Get Field Name and Type of Database Table

Today we will see how we can retrieve table’s columns’ names and types. USE mydatabase GO   SELECT column_name, data_type FROM information_schema.columns WHERE TABLE_NAME = ‘mytable’;use mydatabase go SELECT column_name, data_type FROM information_schema.columns WHERE table_name = ‘mytable’;

Databases, Microsoft SQL Server

Retrieve useful information from SQL Server

Today we will see how can we retrieve various information from Microsoft SQL Server using SQL queries. Get all users: SELECT * FROM sys.server_principals;SELECT * fROM sys.server_principals; Get database size: USE master GO   EXEC sp_spaceuseduse master go exec sp_spaceused Get user privilleges for current database: USE master GO   SELECT SYSOBJECTS.name AS ‘objectname’, SYSUSERS.name …

Android, Java

Retrieve longitude and latitude in Android

You can get your last geo location in Android with this code: 1 2 3 4 5 6 7 8 LocationManager lm = (LocationManager)activity.getSystemService(Context.LOCATION_SERVICE); Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); double longitude = 0; double latitude = 0; if(location!=null){ longitude = location.getLongitude(); latitude = location.getLatitude(); }LocationManager lm = (LocationManager)activity.getSystemService(Context.LOCATION_SERVICE); Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); double longitude = 0; …

Databases, MySQL

Retrieve useful information from MySQL

Today we will see how can we retrieve various information from mysql server using SQL queries. Get all users: SELECT * FROM mysql.user;select * from mysql.user; Get top 10 tables in size: SELECT concat(table_schema,’.’,TABLE_NAME) TABLE_NAME, concat(round(data_length/(1024*1024),2),’M’) data_length FROM information_schema.TABLES ORDER BY data_length DESC LIMIT 10;SELECT concat(table_schema,’.’,table_name) table_name, concat(round(data_length/(1024*1024),2),’M’) data_length FROM information_schema.TABLES ORDER BY data_length DESC …

Apache, Linux

Retrieve useful information from Apache logs

Common locations where you can find Apache logs are /var/log/apache2 and /var/log/httpd/. You can extract valuable information from your apache logs. Here are some useful examples! Extract unique IP addresses: cat /var/log/apache2/access.log | awk ‘{print $1}’ | sort | uniqcat /var/log/apache2/access.log | awk ‘{print $1}’ | sort | uniq   Extract unique IP addresses with …

C#, Microsoft Windows

Get HTTP headers with C#

If you would like to get HTTP headers in C#, you can do it with a few lines of code! 1 2 3 4 5 6 7 8 9 String url = "http://www.site.com";   WebRequest webrequest = HttpWebRequest.Create(url); WebResponse webresponse = webrequest.GetResponse();   foreach (String key in webresponse.Headers) Console.WriteLine("{0}: {1}", key, webresponse.Headers[key]);   webresponse.Close();String url …