Saturday 30 March 2013

Solution: PHP setcookie Warning: Cannot modify header information - headers already sent

Solution: PHP setcookie Warning: Cannot modify header information - headers already sent to avoid this problem add ob_start() at beginning of php and add ob_end_flush() at end of php code like below


<?php
    ob_start(); // Initiate the output buffer

//your code

    ob_end_flush(); // Flush the output from the buffer
?>
Read More

Wednesday 27 March 2013

How to Flush route table in Linux

To remove or Flush all entries in route table the command used is

root@system1:~#  ip route flush table main

Run Above command as root
Read More

Friday 22 March 2013

PHP Replace new lines, tabs and multiple spaces with single space


preg_replace('/\\s+/', ' ',$data) used to Replace new lines, tabs and multiple spaces with single space in PHP

example:
<?php
$data = 'Hi     tab i am 
new line    more                spaces';
$data= preg_replace('/\\s+/', ' ',$data);
echo $data;
?>

Output:

Hi tab i am new line more spaces

Read More

Monday 18 March 2013

Upgrade Cent OS from any version to Any version

To Upgrade CentOS the common command used is yum update. This is used to Upgrade Cent OS from any version to Any version.

command:
As a Root
root@system1# yum update
Read More

Find the size of folders in linux

Finding the size of a directory and finding the amount of free disk space that exists on your machine. The command you would use to find the directory size is ' du '. And to find the free disk space you could use ' df '.


$ du
Gives you a list of directories that exist in the current directory along with their sizes. The last line of the output gives you the total size of the current directory including its subdirectories. Note that by default the sizes given are in kilobytes. 

$ du /home
The above command would give you the directory size of the directory /home

$ du -h
This command gives you a better output than the default one. The option '-h' stands for human readable format. So the sizes of the files / directories are this time suffixed with a 'k' if its kilobytes and 'M' if its Megabytes and 'G' if its Gigabytes.

$ du -sh ./*
Give you total size of each folder and files in present folder
Read More

XOR of Hexadecimals in C program Example

To do XOR in in C the operator used is "^"


#include<stdio.h>
int main()
{
 int x;
 int y;
 int res;
 printf("\n Please enter the value for first number in hex format:");
 scanf("%x",&x); //reading hexadecimal value
 printf("\n Please enter the value for second number in hex format:");
 scanf("%x",&y);
 res=x^y;
 printf("\n The XOR of two numbers is: %x",res);
}
Read More

Solution: Access Variables in Different C files

To access variables in different C files, check below example

header.h 
extern int a;

file1.c
#include</root/path/header.h>
int a;
a = 20;

file2.c
#include</root/path/header.h>
printf("a value is %d",a);

Note: if you compile individual file and check then you may get error 
Compile like:
gcc file1.c file2.c -o out
./out
Output: a value is 20
Read More

Solution: warning: ISO C90 forbids mixed declarations and code

If you get above warning means in your code operation code in between deceleration see below example

Invalid Code:
main(){
int a;
a = function1();
int b;
b = function2();
}

Valid Code:
main(){
int a;
int b;
a = function1();
b = function2();


So write all declarations one place
Read More

Tuesday 12 March 2013

Set Up SCTP in Linux From SCTP Module

Fedora has SCTP kernel as the kernel module, kernel recompile is not needed for our case. Instead, the SCTP kernel module is simply needed to be loaded into the RAM memory on the Fedora with the command ‘modprobe’. The command ‘modprobe SCTP’ plays a role on loading SCTP module into the RAM; see Figure 1


Figure 1 Load SCTP module into the kernel

The SCTP module should be loaded on both the server and the client. After that, it can be assumed that both the server and client have already configured the Linux platform so that they are capable of supporting the SCTP protocol. The next step is to activate the DAR extension of SCTP, to ensure that mSCTP is supported by Linux. The parameter ‘addip_enable’ is the indicator whether DAR extension is active or not. When ‘addipenable’ is 0, Add-IP extension is inactive while it is active when ‘addip-enable’ is 1.
Command ‘echo 1>/proc/sys/net/sctp/addip_enable’ is used to make Linux support mSCTP. Command ‘more /proc/sys/net/sctp/addip_enable’ approves the information.





Figure 2 Active Add-IP extension of SCTP

One problem with the SCTP protocol in Linux is that it does not support SCTP APIs itself, while SCTP APIs are required to be used for coding the mSCTP handover. At this point, we downloaded an additional tool from http://sourceforge.net/projects/lksctp/files/ called LKSCTP, which is able to provide SCTP API functions. There are many versions of the LKSCTP tool, the latest one is 1.0.11. The one used in our testbed is version 1.0.10. The following steps have been taken to build LKSCTP in Linux:
  • Become root user to install LKSCTP by command: su –
  • Enter the LKSCTP directory containing the download RPM files of LKSCTP by command cd /root/sctpfolder (directory).
  • Install the RPM flies by command: rpm *.lksctp-tools-1.0.10-1.rpm
  • Other way is from source Untar the LKSCTP tools directory from the gzipped tarball by command: tar –xzvf lksctp-tools-1.0.10.tar
  • Enter the LKSCTP tool directory by command: cd /lksctp-tools-1.0.10
  • configure LKSCTP by command: ./configure
  • make LKSCTP by command: make
After the success of “make” operation, the LKSCTP tools has been loaded into the Linux
kernel. The following Figure shows how to check whether LKSCTP is supported by
Linux or not.

Figure 3 LKSCTP tools for Linux


In Figure 3, the command ‘checksctp’ indicates whether the server and the client support LKSCTP or not. The result shows that both of them support LKSCTP


Read More

Sunday 10 March 2013

Jquery Mobile header footer moving problem while click

This post will show how to avoid header, footer moving up and down while clicking
to avoid this problem add data-tap-toggle="false" at header and footer
example:


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>App</title>
<meta content="width=device-width, minimum-scale=1, maximum-scale=1" name="viewport">
<link rel="stylesheet" href="includes/jquery.mobile-1.3.0-beta.1.min.css" />
<link rel="stylesheet" href="includes/styles.css" />
<script src="includes/jquery-1.9.0.min.js"></script>
<script src="includes/jquery.mobile-1.3.0-beta.1.min.js"></script>
</head>
<body>
    <div data-role="page" id="home">
        <div data-role="header" data-position="fixed" data-tap-toggle="false">
            Header
        </div>
        <div data-role="content">
            <h1>Hi</h1>
        </div>
        <div data-role="footer" data-position="fixed" data-tap-toggle="false">By Footer</div>
    </div>
</body>
Read More

Thursday 7 March 2013

Upgrade Backtrack 5 R2 to R3

To upgrade Backtrack 5 R2 to R3 follow below steps

System@bt# sudo apt-get update && apt-get dist-upgrade

For 32 bit Systems

System@bt# apt-get install libcrafter blueranger dbd inundator intersect mercury cutycapt trixd00r artemisa rifiuti2 netgear-telnetenable jboss-autopwn deblaze sakis3g voiphoney apache-users phrasendrescher kautilya manglefizz rainbowcrack rainbowcrack-mt lynis-audit spooftooph wifihoney twofi truecrack uberharvest acccheck statsprocessor iphoneanalyzer jad javasnoop mitmproxy ewizard multimac netsniff-ng smbexec websploit dnmap johnny unix-privesc-check sslcaudit dhcpig intercepter-ng u3-pwn binwalk laudanum wifite tnscmd10g bluepot dotdotpwn subterfuge jigsaw urlcrazy creddump android-sdk apktool ded dex2jar droidbox smali termineter bbqsql htexploit smartphone-pentest-framework fern-wifi-cracker powersploit webhandler

For 64 bit Systems

System@bt# apt-get install libcrafter blueranger dbd inundator intersect mercury cutycapt trixd00r rifiuti2 netgear-telnetenable jboss-autopwn deblaze sakis3g voiphoney apache-users phrasendrescher kautilya manglefizz rainbowcrack rainbowcrack-mt lynis-audit spooftooph wifihoney twofi truecrack acccheck statsprocessor iphoneanalyzer jad javasnoop mitmproxy ewizard multimac netsniff-ng smbexec websploit dnmap johnny unix-privesc-check sslcaudit dhcpig intercepter-ng u3-pwn binwalk laudanum wifite tnscmd10g bluepot dotdotpwn subterfuge jigsaw urlcrazy creddump android-sdk apktool ded dex2jar droidbox smali termineter multiforcer bbqsql htexploit smartphone-pentest-framework fern-wifi-cracker powersploit webhandler
Read More

Solution : Backtrack 5 apt-get upgrade error var/lib/dpkg/info/w3af.postins

If you ger below error ,simply download missing file to /tmp folder


system@bt:~# apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages have been kept back:
  smartphone-pentest-framework
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
1 not fully installed or removed.
After this operation, 0B of additional disk space will be used.
Do you want to continue [Y/n]? y
Setting up w3af (1.2-bt2) ...
tar: pybloomfiltermmap-0.2.0.tar.gz: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Exiting with failure status due to previous errors
/var/lib/dpkg/info/w3af.postinst: line 4: cd: pybloomfiltermmap-0.2.0: No such file or directory
python: can't open file 'setup.py': [Errno 2] No such file or directory

system@bt:~# cd /tmp
system@bt:/tmp# 
wget http://pypi.python.org/packages/source/p/pybloomfiltermmap/pybloomfiltermmap-0.2.0.tar.gz

Now run upgrade
system@bt:~# apt-get upgrade

Read More

Solution : dpkg: warning: parsing file 'magic tree':error in Version string 'r1643-bt0': version number does not start with digit


If you get error like below Simple remove packages which are causing error
                                          
dpkg: warning: parsing file '/var/lib/dpkg/status' near line 5812 package 'magictree':
 error in Version string 'r1643-bt0': version number does not start with digit
dpkg: warning: parsing file '/var/lib/dpkg/status' near line 16762 package 'udptunnel':
 error in Version string 'r19-bt0': version number does not start with digit
dpkg: warning: parsing file '/var/lib/dpkg/status' near line 21351 package 'untidy':
 error in Version string 'beta2-bt1': version number does not start with digit
dpkg: warning: parsing file '/var/lib/dpkg/status' near line 24439 package 'pwntcha':
 error in Version string 'rev4780-bt3': version number does not start with digit
dpkg: warning: parsing file '/var/lib/dpkg/status' near line 40987 package 'webslayer':
 error in Version string 'rev5-bt0': version number does not start with digit
dpkg: warning: parsing file '/var/lib/dpkg/status' near line 46097 package 'protos-sip':
 error in Version string 'r2-bt1': version number does not start with digit
dpkg: error processing /var/cache/apt/archives/magictree_r1802-bt0_all.deb (--unpack):
 parsing file '/var/lib/dpkg/tmp.ci/control' near line 3 package 'magictree':
 error in Version string 'r1802-bt0': version number does not start with digit
Errors were encountered while processing:
 /var/cache/apt/archives/magictree_r1802-bt0_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Remove above packages
System1# apt-get remove magictree udptunnel untidy pwntcha webslayer protos-sip
Read More

Solution : Error while processing magictree_r1802-bt0_all.deb Sub-process /usr/bin/dpkg returned an error code (1)


If you get Error Like Below

Errors were encountered while processing:
 /var/cache/apt/archives/magictree_r1802-bt0_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Simply delete the file which causing Error

system1# rm -rf /var/cache/apt/archives/magictree_r1802-bt0_all.deb
Read More

Add HTTP Proxy to SVN - Subversion

Below Instructions show how to setup proxy for SVN -Subversion

system1# cd ~/.subversion
system1# ls

auth  config  README.txt  servers

Edit servers file
system1# gedit servers
Add Below Lines to servers file
[global]
http-proxy-host = your_ipaddress
http-proxy-port = 3128
http-proxy-compression = no
Read More
Here We Write The Problems we face at different situations and Solutions to those problems.