Sunday, January 24, 2016

Cài đặt Webgoat 7.0

Webgoat là một ứng dụng Java, để sử dụng nó chúng ta phải cài đặt Java virtual machine (Java VM >= 1.6)
Sử dụng webgoat để test các vấn đề liên quan đến bảo mật trên website
  • Cross-site Scripting (XSS)
  • Access Control
  • Thread Safety
  • Hidden Form Field Manipulation
  • Parameter Manipulation
  • Weak Session Cookies
  • SQL Injection
  • Numeric SQL Injection
  • String SQL Injection
  • Web Services
  • Fail Open Authentication
  • Dangers of HTML Comments
  • ... and many more!

Hướng dẫn cài đặt Java VM

+ B1: Truy cập vào địa chỉ: http://www.oracle.com/technetwork/java/javase/downloads/index.html
+ B2: Chọn JDK

+ B3: Chọn phiên bản download cho window và tiến hành cài đặt.

Tiếp theo là phần cài đặt Webgoat

+ B1: Download file xử lý bao gồm các bài học và tomcat server: https://s3.amazonaws.com/webgoat-war/webgoat-container-7.0-SNAPSHOT-war-exec.jar
+ B2: Chạy file jar vừa download về.(Đối với Windows đa phần đều chạy được)
Nếu không chạy được thì sử dụng cmd để chạy.(Đối với linux hay Mac)
Sau khi mở cmd ta trỏ đến thư mục chứa file jar
+ B21: cd /Users/sun/Greatmissionit/Cao\ hoc/HKII/QL\:\ ATBMTT\ -\ Thay\ Hau/Lab1
+ B22: java -jar webgoat-container-7.0-SNAPSHOT-war-exec.jar
Mở web browser lên, truy cập vào http://localhost:8080/WebGoat

+ Nhập: user: guest pass: guest nếu là Webgoat User
+ Nhập: user: webgoat pass: webgoat nếu là Webgoat Admin
Tham khảo : https://github.com/WebGoat/WebGoat

Monday, May 4, 2015

Make a simple equation in blogger

The first: we add a script:

So, we can write something math equation like:
       
When $$a \ne 0$$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x ={-b\pm \sqrt{b^2-4ac} \over 2a}.$$.
            
Some format like coding in Latex. And the result as below:
When $$a \ne 0$$, there are two solutions to \(ax^2 + bx + c = 0\) and they are $$x = {-b \pm \sqrt{b^2-4ac} \over 2a}.$$

Sunday, March 1, 2015

Left Menu like on Mobile simple

Created 3 files like index.html, app.js, style.css like below:

In file index.html:


<html>
  <head>
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400;300' rel='stylesheet' type='text/css'>
    <link href='style.css' rel='stylesheet'>

  </head>
  <body>

    <div class="menu">
     
      <!-- Menu icon -->
      <div class="icon-close">
        <img src="http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/uber/close.png">
      </div>

      <!-- Menu -->
      <ul>
        <li><a href="#">About</a></li>
        <li><a href="#">Blog</a></li>
        <li><a href="#">Help</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </div>

    <!-- Main body -->
    <div class="jumbotron">

      <div class="icon-menu">
        <i class="fa fa-bars"></i>
        Menu
      </div>
   
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="app.js"></script>
  </body>
</html>


In file app.js :

var main = function() {
  /* Push the body and the nav over by 285px over */
  $('.icon-menu').click(function() {
    $('.menu').animate({
      left: "0px"
    }, 200);

    $('body').animate({
      left: "285px"
    }, 200);
  });

  /* Then push them back */
  $('.icon-close').click(function() {
    $('.menu').animate({
      left: "-285px"
    }, 200);

    $('body').animate({
      left: "0px"
    }, 200);
  });
};


$(document).ready(main);

In file style.css:

/* Initial body */
body {
  left: 0;
  margin: 0;
  overflow: hidden;
  position: relative;
}

/* Initial menu */
.menu {
  background: #202024 url('http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/uber/black-thread.png') repeat left top;
  left: -285px;  /* start off behind the scenes */
  height: 100%;
  position: fixed;
  width: 285px;
}

/* Basic styling */

.jumbotron {
  background-image: url('http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/uber/bg.png');
  height: 100%;
  -webkit-background-size: cover;
     -moz-background-size: cover;
       -o-background-size: cover;
          background-size: cover;
}

.menu ul {
  border-top: 1px solid #636366;
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu li {
  border-bottom: 1px solid #636366;
  font-family: 'Open Sans', sans-serif;
  line-height: 45px;
  padding-bottom: 3px;
  padding-left: 20px;
  padding-top: 3px;
}

.menu a {
  color: #fff;
  font-size: 15px;
  text-decoration: none;
  text-transform: uppercase;
}

.icon-close {
  cursor: pointer;
  padding-left: 10px;
  padding-top: 10px;
}

.icon-menu {
  color: #fff;
  cursor: pointer;
  font-family: 'Open Sans', sans-serif;
  font-size: 16px;
  padding-bottom: 25px;
  padding-left: 25px;
  padding-top: 25px;
  text-decoration: none;
  text-transform: uppercase;
}

.icon-menu i {
  margin-right: 5px;
}

Wednesday, February 11, 2015

Redis on Codeigniter Tutorial


Chia làm 5 loại dữ liệu khác nhau:

STRING: thể string, integer hoặc float. Redis thể làm việc với cả string, từng phần của string, cũng như tăng/giảm giá trị của integer, float.
LIST: Danh sách liên kết của các strings. Redis hỗ trợ các thao tác push, pop từ cả 2 phía của list, trim dựa theo offset, đọc 1 hoặc nhiều items của list, tìm kiếm xóa giá trị.
SET: Tập hợp các string (không được sắp xếp). Redis hỗ trợ các thao tác thêm, đọc, xóa từng phần tử, kiểm tra sự xuất hiện của phần tử trong tập hợp. Ngoài ra Redis còn hỗ trợ các phép toán tập hợp, gồm intersect/union/difference.
HASH: Lưu trữ hash table của các cặp key-value, trong đó key được sắp xếp ngẫu nhiên, không theo thứ tự nào cả. Redis hỗ trợ các thao tác thêm, đọc, xóa từng phần tử, cũng như đọc tất cả giá trị.
ZSET (sorted set): 1 danh sách, trong đó mỗi phần tử map của 1 string (member) 1 floating-point number (score), danh sách được sắp xếp theo score này. Redis hỗ trợ thao tác thêm, đọc, xóa từng phần tử, lấy ra các phần tử dựa theo range của score hoặc của string.
 
   

Download, extract and compile Redis with:

$ wget http://download.redis.io/releases/redis-2.8.19.tar.gz
$ tar xzf redis-2.8.19.tar.gz
$ cd redis-2.8.19
$ make

The binaries that are now compiled are available in the src directory. Run Redis with:

$ src/redis-server

You can interact with Redis using the built-in client:

$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

Config with CI

Go to https://github.com/joelcox/codeigniter-redis and clone source down computer.
Copy Redis.php file in libraries to application\libraries in CI. Then, copy redis.php file in config to application\config in CI.
Open autoload.php in application\config in CI add more libraries “redis” like that image:

Thực hiện tạo 1 sample Redis trong Codeigniter:

Tại Controller: tạo file content.php (controller/gallery/content.php)