Monday, 24 September 2012

html & css

CSS:- CSS stands on Cascading Style Sheet. It's used for display the HTML content on web page. Style sheet file extension is .css.

We can add style sheet in html file by using the '<link />' tag. For example.
<link rel="stylesheet" href="http://myresarch.blogspot.com/mystyle.css" type="text/css"/>

And we can add open css in html file by using the '<style />' tag. For example:-
<style type="text/css">
   body {
        background-color:#d0b4fb;
   }
   h1 {
      color:green;
      font-family:"Times New Roman";
      font-size:20px;
  }
</style>


Some example of css is:-

1. Full Screen overlay:-
       .blackOverlay{
            height:100%;
            width:100%;
            position:fixed;
            left:0;
            top:0;
            z-index:9999 !important;
            background-color:black;
       }

2. Rotate Text using css:-

-webkit-transform: rotate(269deg);
-moz-transform: rotate(269deg);
-o-transform: rotate(269deg);
writing-mode: rl-tb;

.rotate {
     -moz-transform: rotate(-90.0deg);  /* FF3.5+ */
       -o-transform: rotate(-90.0deg);  /* Opera 10.5 */
  -webkit-transform: rotate(-90.0deg);  /* Saf3.1+, Chrome */
             filter:  progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083);  /* IE6,IE7 */
         -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)"; /* IE8 */
}


$(document).ready(function () {
    $('.rotate').css('height', $('.rotate').width());
});

-webkit-transform: rotate(269deg);

Tuesday, 21 August 2012

Examples of Springs

How use Application context in core application:-

ApplicationContext context =
           new ClassPathXmlApplicationContext("applicationContext.xml");
//System.out.println( context.getBean("AutowiredBeansDetail") );
AutowireCapableBeanFactory acbf = context.getAutowireCapableBeanFactory();
acbf.autowire(AutowiredBeansDetail.class, acbf.AUTOWIRE_CONSTRUCTOR, true);
acbf.autowireBean(AutowiredBeansDetail.class);
AutowiredBeansDetail autowiredBeansDetail = acbf.getBean(AutowiredBeansDetail.class);

List<Songs> downloadable = autowiredBeansDetail.getSongsService().getDownloadableSongs ("s1,s2");
for(Games dgmlist : downloadableSongsList) {
System.out.println(dgmlist.getSongid());
}



Tuesday, 14 August 2012

Using of Ant

Firstly download ant package from Apache site.
http://ant.apache.org/antlibs/bindownload.cgi

After downloading the ant package extract the package and follow below metioned steps:-

How to set Environment variable in linux
Create a file with name of ant_file.sh  in directory (i.e.  /etc/profile.d/ )

vi /etc/profile.d/ant_file.sh
Add the following contents:

#!/bin/bash
ANT_HOME=/opt/ant
PATH=$ANT_HOME/bin:$PATH
export PATH ANT_HOME
export CLASSPATH=.

Save and close the file.  (:wq!)

#> chmod +x /etc/profile.d/ant_file.sh
Set environment variables permanently by running the following command:

#> source /etc/profile.d/ant_file.sh

Now, check the ant install with ant version using command:

#> ant -version

Example of Ant:-


<project name="JSD" default="war" basedir=".">
    <description>
        jsd education War file
    </description>
  <!-- set global properties for this build -->
  <property environment="env"/>
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="lib.dir" value="WebContent/WEB-INF/lib"/>



 <path id="compile.classpath">
        <fileset dir="${lib.dir}">
            <include name="**/*.jar"/>
        </fileset>

  </path>

  <target name="init" depends="clean">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}/classes"/>
  </target>

  <target name="compile" depends="init" description="compile the source " >
    <!-- Compile the java code from ${src} into ${build} -->
<path id="lib.path.ref">
<fileset dir="" includes="*.jar"/>
</path>
    <javac srcdir="${src}" destdir="build/classes">
<classpath refid="compile.classpath"/>
</javac>
<copy todir="build/classes" flatten="no">
            <fileset dir="${src}">
                <include name="**/*.xml"/>
            </fileset>
    </copy>
  </target>


  <target name="war" depends="compile" description="generate the distribution" >
    <!-- Create the distribution directory -->
<copy todir="build/classes" flatten="no">
            <fileset dir="${src}">
                <include name="/com/jsd/education/db/dao/hbm/*.xml"/>
             
            </fileset>
        </copy>
 
<war destfile="${build}/JSD.war" webxml="WebContent/WEB-INF/web.xml">

 <classes dir="build/classes"/>
 <fileset dir="WebContent">
  <exclude name="**/*.jar"/>
 </fileset>
 <exclude name="${lib.dir}/*.jar"/>
</war>
<delete dir="${build}/classes"/>
  </target>

  <target name="clean"
        description="clean up" >
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
  </target>


</project>

Thursday, 19 July 2012

Tutorial on XSS

XSS Call by using AJAX:-

1. For xml files:-
eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('o.e.7=9(){0=5(6);0=0.1(":","%8");0=0.1("//","%2%2");0=0.1("/","%2");0="a://b.c.d/4/f/g?q=h%i*%j%k%l%m%n%3"+0+"%3&p=r";s 0}',29,29,'url|replace|2F|22|v1|encodeURI|this|crossDomainXMLURL|3A|function|http|query|yahooapis|com|prototype|public|yql|select|20|20from|20xml|20where|20url|3D|String|diagnostics||true|return'.split('|'),0,{}))

2. For JSON response:-

eval(function(p,a,c,k,e,r){e=function(c){return c.toString(a)};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('o.f.7=9(){0=5(6);0=0.1(":","%8");0=0.1("//","%2%2");0=0.1("/","%2");0="a://b.c.d/e/4/g?q=h%i*%j%k%l%m%n%3"+0+"%3&p=r&s=t";u 0}',31,31,'url|replace|2F|22|public|encodeURI|this|crossDomainJSONURL|3A|function|http|query|yahooapis|com|v1|prototype|yql|select|20|20from|20json|20where|20url|3D|String|diagnostics||true|format|json|return'.split('|'),0,{}))

JAVA CODE FOR XSS:-


               response.setHeader("Access-Control-Allow-Origin", "*");
response.setContentType("application/xml");
HttpClient client = new HttpClient();
HttpMethod method = new GetMethod(rqurl);

client.setConnectionTimeout(20000);
client.setTimeout(20000);
client.executeMethod(method);

String sb = method.getResponseBodyAsString().replaceAll("\r","").replaceAll("\n", "").replaceAll("\t", "");
method.releaseConnection();
client = null;
        return sb.toString();


HEADERS:-
X-Frame-Options
Access-Control-Allow-Origin
Future Reading:-
http://blog.whitehatsec.com/category/web-application-security/ 
http://blog.whitehatsec.com/x-frame-options-xfo-detection-from-javascript/#comment-392