Advertisement
pexea12

Thief UET

Dec 3rd, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var casper = require('casper').create({
  2.     viewportSize: {width: 2000, height: 2000}
  3. });
  4. var utils = require('utils');
  5.  
  6. var username = casper.cli.args[0];
  7. var password = casper.cli.args[1];
  8.  
  9. var subjects = [
  10.     'PES1030 04',
  11.     'PES1015 35',
  12.     'PES1015 36',
  13.     'PES1025 3',
  14.     'PES1020 39',
  15.     'PES1035 5',
  16.     'PES1035 8',
  17.     'PES1050 17',
  18. ];
  19. var cur = 0;
  20.  
  21. function register() {
  22.     casper.thenOpen('http://dangkyhoc.daotao.vnu.edu.vn/dang-nhap');
  23.  
  24.     casper.then(function () {
  25.         this.echo(username + ' ' + cur++);
  26.         this.fill('form[action="/dang-nhap"]', {
  27.             'LoginName': username,
  28.             'Password': password
  29.         }, true);
  30.     });
  31.  
  32.     casper.thenEvaluate(function () {
  33.         document.querySelector('button.btn').submit();
  34.     });
  35.  
  36.     casper.waitForSelector('title');
  37.  
  38.     casper.then(function () {
  39.         if (this.getTitle() == 'Đăng nhập hệ thống đăng ký học - Cổng thông tin Đào tạo Đại học VNU')
  40.             this.die('Wrong password!', 1);
  41.     });
  42.  
  43.     casper.thenOpen('http://dangkyhoc.daotao.vnu.edu.vn/dang-ky-mon-hoc-nganh-1');
  44.  
  45.     casper.wait(5000);
  46.  
  47.  
  48.     casper.then(function () {
  49.         var data = this.getElementsInfo('div.green-border table tbody tr td:nth-child(5)').map(function (value, index, array) {
  50.             var subject = array[index].text.substr(17);
  51.             return subject.substring(0, subject.indexOf('\n'));
  52.         });
  53.         var code = this.getElementsInfo('div.green-border table tbody tr td:nth-child(1)').map(function (value, index, array) {
  54.             var subject = array[index].html;
  55.             subject = subject.substring(subject.indexOf('data-crdid'));
  56.             return subject.substring(12, 19);
  57.         });
  58.            
  59.         for (var i = 0; i < code.length; ++i) {
  60.             if (code[i].charAt(0) == '0')
  61.                 for (var j = 0; j < subjects.length; ++j)
  62.                     if (subjects[j] == data[i]) {
  63.                         this.echo('Found ' + data[i]);
  64.                         this.thenEvaluate(function (codename) {
  65.                             document.querySelector('input[data-crdid="' + codename + '"]').click();                    
  66.                         }, code[i]);
  67.                         this.wait(5000);
  68.                         this.thenEvaluate(function() {
  69.                             document.querySelector('button.confirm-registration').click();
  70.                         });
  71.                     }
  72.         }
  73.     });
  74. }
  75.  
  76. casper.start();
  77.  
  78. casper.then(function () {
  79.     this.repeat(10000, register);
  80. });
  81.  
  82. casper.run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement