특수한 경우에 한하지만, PHP가 없는 환경에서 기존 환경을 최대한 해치지 않고 PHP 라이브러리를 호출하는 최선의 방법을 고민하며 나온 결과물을 공유해봅니다.
사용 예시:
> set target https://public-api.example.org
> set method relay_invoke_method
method(relay_invoke_method)> set requires https://raw.githubusercontent.com/dimamedia/PHP-Simple-TOTP-and-PubKey/refs/heads/master/class.tfa.php
method(relay_invoke_method)> show env
{
"target": "https://public-api.example.org",
"method": "relay_invoke_method",
"filename": null,
"requires": [
]
}
method(relay_invoke_method)> do load_script "$tfa = new tfa(); return $tfa->getPubKey()"
RESB 4Y24 3U2K OA2W
method(relay_invoke_method)> do load_script "$tfa = new tfa(); return $tfa->getOtp('RESB 4Y24 3U2K OA2W')"
174053
method(relay_invoke_method)>
서버에 "class.tfa.php"라는 클래스 파일을 전혀 업로드하지 않았으나, 깃허브(또는 공개된 URL)에서 호스팅되고 있는 PHP 파일 주소를 입력하는 것만으로도 바로 불러와서 라이브러리로 활용한 사례입니다.
사용 방법:
1. JSON-RPC 2.0 형식을 해석하고 명령 수행이 가능한 PHP 스크립트를 내려받고 서버에 올린다.
https://github.com/gnh1201/caterpillar/blob/main/assets/php/index.php
2. 사용 예시의 실제 메시지는 다음과 같다. 스크립트가 있는 위치에 POST 요청을 보내어 사용할 수 있다.
요청 예시:
{
"jsonrpc": "2.0",
"method": "relay_invoke_method",
"params": {
"callback": "load_script",
"requires": [
"https://raw.githubusercontent.com/dimamedia/PHP-Simple-TOTP-and-PubKey/refs/heads/master/class.tfa.php"
],
"args": [
"$tfa = new tfa(); return $tfa->getPubKey()"
]
},
"id": null
}
응답 예시:
{
"jsonrpc": "2.0",
"result": {
"status": 200,
"data": "B7FJ 43QC 7WCX CLAY"
},
"id": null,
"_execution_time": 0.017116069793701
}
보안 정책만 잘 조정하여 사용할 수 있다면 특수한 경우에 유용할 것으로 보입니다.
댓글 4개
게시글 목록
| 번호 | 제목 |
|---|---|
| 17591 |
node.js
노드로 멀티스레드 기능 구현하기
2
|
| 17590 | |
| 17589 |
PHP
PHP로 인쇄명령주기
1
|
| 17588 |
JavaScript
Javascript로 JSON데이터를 보기좋게 만들기
|
| 17587 | |
| 17584 | |
| 17583 |
MySQL
MySQL과 PostgreSQL의 우단점
|
| 17582 |
MySQL
프로시저 cursor 사용 예
|
| 17581 |
JavaScript
바닐라 ajax 파일업로드 예제
|
| 17579 | |
| 17577 | |
| 17575 | |
| 17574 | |
| 17573 | |
| 17572 | |
| 17569 | |
| 17564 | |
| 17560 | |
| 17559 |
MySQL
프로시저 기본편
|
| 17555 | |
| 17554 | |
| 17553 | |
| 17552 | |
| 17549 | |
| 17548 | |
| 17547 | |
| 17542 | |
| 17533 | |
| 17531 | |
| 17524 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기