«   2018/02   »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28      
Tags
more
Archives
Today
0
Total
1,355
관리 메뉴

z9n

[NodeJS] 원격지 프로그램 실행 본문

NodeJS, NodeWebKit

[NodeJS] 원격지 프로그램 실행

terrorboy 2017.05.19 11:42

[NodeJS] 원격지 프로그램 실행

전문 분야가 아니라 많이 부족합니다.
참조만 부탁 드리며 악용하지 말아주세요.

css/github_custom.css

.md-add {
  padding: 30px;
}
@font-face {
  font-family: octicons-anchor;
  src: url(data:font/woff;charset=utf-8;base64,d09GRgABAAAAAAYcAA0AAAAACjQAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAABMAAAABwAAAAca8vGTk9TLzIAAAFMAAAARAAAAFZG1VHVY21hcAAAAZAAAAA+AAABQgAP9AdjdnQgAAAB0AAAAAQAAAAEACICiGdhc3AAAAHUAAAACAAAAAj//wADZ2x5ZgAAAdwAAADRAAABEKyikaNoZWFkAAACsAAAAC0AAAA2AtXoA2hoZWEAAALgAAAAHAAAACQHngNFaG10eAAAAvwAAAAQAAAAEAwAACJsb2NhAAADDAAAAAoAAAAKALIAVG1heHAAAAMYAAAAHwAAACABEAB2bmFtZQAAAzgAAALBAAAFu3I9x/Nwb3N0AAAF/AAAAB0AAAAvaoFvbwAAAAEAAAAAzBdyYwAAAADP2IQvAAAAAM/bz7t4nGNgZGFgnMDAysDB1Ml0hoGBoR9CM75mMGLkYGBgYmBlZsAKAtJcUxgcPsR8iGF2+O/AEMPsznAYKMwIkgMA5REMOXicY2BgYGaAYBkGRgYQsAHyGMF8FgYFIM0ChED+h5j//yEk/3KoSgZGNgYYk4GRCUgwMaACRoZhDwCs7QgGAAAAIgKIAAAAAf//AAJ4nHWMMQrCQBBF/0zWrCCIKUQsTDCL2EXMohYGSSmorScInsRGL2DOYJe0Ntp7BK+gJ1BxF1stZvjz/v8DRghQzEc4kIgKwiAppcA9LtzKLSkdNhKFY3HF4lK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jLcBZDKrMhUBfQBvXRzLtFtjU9eNHKin0x5InTqb8lNpfKv1s1xHzTXRqgKzek/mb7nB8RZTCDhGEX3kK/8Q75AmUM/eLkfA+0Hi908Kx4eNsMgudg5GLdRD7a84npi+YxNr5i5KIbW5izXas7cHXIMAau1OueZhfj+cOcP3P8MNIWLyYOBuxL6DRylJ4cAAAB4nGNgYoAALjDJyIAOWMCiTIxMLDmZedkABtIBygAAAA==) format('woff');
}

.md-add {
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  color: #333;
  overflow: hidden;
  font-family: "Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  word-wrap: break-word;
}

.md-add a {
  background: transparent;
  display:block;
  border:1px solid #ccc;
  text-align:center;
  padding: 10px;
  margin-top:10px;
}

.md-add a:active,
.md-add a:hover {
  outline: 0;
}

.md-add strong {
  font-weight: bold;
}

.md-add h1 {
  font-size: 2em;
  margin: 0.67em 0;
}

.md-add img {
  border: 0;
}

.md-add hr {
  -moz-box-sizing: content-box;
  box-sizing: content-box;
  height: 0;
}

.md-add pre {
  overflow: auto;
}

.md-add code,
.md-add kbd,
.md-add pre {
  font-family: monospace, monospace;
  font-size: 1em;
}

.md-add input {
  color: inherit;
  font: inherit;
  margin: 0;
}

.md-add html input[disabled] {
  cursor: default;
}

.md-add input {
  line-height: normal;
}

.md-add input[type="checkbox"] {
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  padding: 0;
}

.md-add table {
  border-collapse: collapse;
  border-spacing: 0;
}

.md-add td,
.md-add th {
  padding: 0;
}

.md-add * {
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.md-add input {
  font: 13px/1.4 Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
}

.md-add a {
  color: #4183c4;
  text-decoration: none;
}

.md-add a:hover,
.md-add a:focus,
.md-add a:active {
  text-decoration: underline;
}

.md-add hr {
  height: 0;
  margin: 15px 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #ddd;
}

.md-add hr:before {
  display: table;
  content: "";
}

.md-add hr:after {
  display: table;
  clear: both;
  content: "";
}

.md-add h1,
.md-add h2,
.md-add h3,
.md-add h4,
.md-add h5,
.md-add h6 {
  margin-top: 15px;
  margin-bottom: 15px;
  line-height: 1.1;
}

.md-add h1 {
  font-size: 30px;
}

.md-add h2 {
  font-size: 21px;
}

.md-add h3 {
  font-size: 16px;
}

.md-add h4 {
  font-size: 14px;
}

.md-add h5 {
  font-size: 12px;
}

.md-add h6 {
  font-size: 11px;
}

.md-add blockquote {
  margin: 0;
}

.md-add ul,
.md-add ol {
  padding: 0;
  margin-top: 0;
  margin-bottom: 0;
}

.md-add ol ol,
.md-add ul ol {
  list-style-type: lower-roman;
}

.md-add ul ul ol,
.md-add ul ol ol,
.md-add ol ul ol,
.md-add ol ol ol {
  list-style-type: lower-alpha;
}

.md-add dd {
  margin-left: 0;
}

.md-add code {
  font: 12px Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

.md-add pre {
  margin-top: 0;
  margin-bottom: 0;
  font: 12px Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

.md-add .octicon {
  font: normal normal 16px octicons-anchor;
  line-height: 1;
  display: inline-block;
  text-decoration: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.md-add .octicon-link:before {
  content: '\f05c';
}

.md-add>*:first-child {
  margin-top: 0 !important;
}

.md-add>*:last-child {
  margin-bottom: 0 !important;
}

.md-add .anchor {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: block;
  padding-right: 6px;
  padding-left: 30px;
  margin-left: -30px;
}

.md-add .anchor:focus {
  outline: none;
}

.md-add h1,
.md-add h2,
.md-add h3,
.md-add h4,
.md-add h5,
.md-add h6 {
  position: relative;
  margin-top: 1em;
  margin-bottom: 16px;
  font-weight: bold;
  line-height: 1.4;
}

.md-add h1 .octicon-link,
.md-add h2 .octicon-link,
.md-add h3 .octicon-link,
.md-add h4 .octicon-link,
.md-add h5 .octicon-link,
.md-add h6 .octicon-link {
  display: none;
  color: #000;
  vertical-align: middle;
}

.md-add h1:hover .anchor,
.md-add h2:hover .anchor,
.md-add h3:hover .anchor,
.md-add h4:hover .anchor,
.md-add h5:hover .anchor,
.md-add h6:hover .anchor {
  padding-left: 8px;
  margin-left: -30px;
  line-height: 1;
  text-decoration: none;
}

.md-add h1:hover .anchor .octicon-link,
.md-add h2:hover .anchor .octicon-link,
.md-add h3:hover .anchor .octicon-link,
.md-add h4:hover .anchor .octicon-link,
.md-add h5:hover .anchor .octicon-link,
.md-add h6:hover .anchor .octicon-link {
  display: inline-block;
}

.md-add h1 {
  padding-bottom: 0.3em;
  font-size: 2.25em;
  line-height: 1.2;
  border-bottom: 1px solid #eee;
}

.md-add h2 {
  padding-bottom: 0.3em;
  font-size: 1.75em;
  line-height: 1.225;
  border-bottom: 1px solid #eee;
}

.md-add h3 {
  font-size: 1.5em;
  line-height: 1.43;
}

.md-add h4 {
  font-size: 1.25em;
}

.md-add h5 {
  font-size: 1em;
}

.md-add h6 {
  font-size: 1em;
  color: #777;
}

.md-add p,
.md-add blockquote,
.md-add ul,
.md-add ol,
.md-add dl,
.md-add table,
.md-add pre {
  margin-top: 0;
  margin-bottom: 16px;
}

.md-add hr {
  height: 4px;
  padding: 0;
  margin: 16px 0;
  background-color: #e7e7e7;
  border: 0 none;
}

.md-add ul,
.md-add ol {
  padding-left: 2em;
}

.md-add ul ul,
.md-add ul ol,
.md-add ol ol,
.md-add ol ul {
  margin-top: 0;
  margin-bottom: 0;
}

.md-add li>p {
  margin-top: 16px;
}

.md-add dl {
  padding: 0;
}

.md-add dl dt {
  padding: 0;
  margin-top: 16px;
  font-size: 1em;
  font-style: italic;
  font-weight: bold;
}

.md-add dl dd {
  padding: 0 16px;
  margin-bottom: 16px;
}

.md-add blockquote {
  padding: 0 15px;
  color: #777;
  border-left: 4px solid #ddd;
}

.md-add blockquote>:first-child {
  margin-top: 0;
}

.md-add blockquote>:last-child {
  margin-bottom: 0;
}

.md-add table {
  display: block;
  width: 100%;
  overflow: auto;
  word-break: normal;
  word-break: keep-all;
}

.md-add table th {
  font-weight: bold;
}

.md-add table th,
.md-add table td {
  padding: 6px 13px;
  border: 1px solid #ddd;
}

.md-add table tr {
  background-color: #fff;
  border-top: 1px solid #ccc;
}

.md-add table tr:nth-child(2n) {
  background-color: #f8f8f8;
}

.md-add img {
  max-width: 100%;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.md-add code {
  padding: 0;
  padding-top: 0.2em;
  padding-bottom: 0.2em;
  margin: 0;
  font-size: 85%;
  background-color: rgba(0,0,0,0.04);
  border-radius: 3px;
}

.md-add code:before,
.md-add code:after {
  letter-spacing: -0.2em;
  content: "\00a0";
}

.md-add pre>code {
  padding: 0;
  margin: 0;
  font-size: 100%;
  word-break: normal;
  white-space: pre;
  background: transparent;
  border: 0;
}

.md-add .highlight {
  margin-bottom: 16px;
}

.md-add .highlight pre,
.md-add pre {
  padding: 16px;
  overflow: auto;
  font-size: 85%;
  line-height: 1.45;
  background-color: #f7f7f7;
  border-radius: 3px;
}

.md-add .highlight pre {
  margin-bottom: 0;
  word-break: normal;
}

.md-add pre {
  word-wrap: normal;
}

.md-add pre code {
  display: inline;
  max-width: initial;
  padding: 0;
  margin: 0;
  overflow: initial;
  line-height: inherit;
  word-wrap: normal;
  background-color: transparent;
  border: 0;
}

.md-add pre code:before,
.md-add pre code:after {
  content: normal;
}

.md-add .highlight {
  background: #fff;
}

.md-add .highlight .h {
  color: #333;
  font-style: normal;
  font-weight: normal;
}

.md-add .highlight .mf,
.md-add .highlight .mh,
.md-add .highlight .mi,
.md-add .highlight .mo,
.md-add .highlight .il,
.md-add .highlight .m {
  color: #945277;
}

.md-add .highlight .s,
.md-add .highlight .sb,
.md-add .highlight .sc,
.md-add .highlight .sd,
.md-add .highlight .s2,
.md-add .highlight .se,
.md-add .highlight .sh,
.md-add .highlight .si,
.md-add .highlight .sx,
.md-add .highlight .s1 {
  color: #df5000;
}

.md-add .highlight .kc,
.md-add .highlight .kd,
.md-add .highlight .kn,
.md-add .highlight .kp,
.md-add .highlight .kr,
.md-add .highlight .kt,
.md-add .highlight .k,
.md-add .highlight .o {
  font-weight: bold;
}

.md-add .highlight .kt {
  color: #458;
}

.md-add .highlight .c,
.md-add .highlight .cm,
.md-add .highlight .c1 {
  color: #998;
  font-style: italic;
}

.md-add .highlight .cp,
.md-add .highlight .cs,
.md-add .highlight .cp .h {
  color: #999;
  font-weight: bold;
}

.md-add .highlight .cs {
  font-style: italic;
}

.md-add .highlight .n {
  color: #333;
}

.md-add .highlight .na,
.md-add .highlight .nv,
.md-add .highlight .vc,
.md-add .highlight .vg,
.md-add .highlight .vi {
  color: #008080;
}

.md-add .highlight .nb {
  color: #0086B3;
}

.md-add .highlight .nc {
  color: #458;
  font-weight: bold;
}

.md-add .highlight .no {
  color: #094e99;
}

.md-add .highlight .ni {
  color: #800080;
}

.md-add .highlight .ne {
  color: #990000;
  font-weight: bold;
}

.md-add .highlight .nf {
  color: #945277;
  font-weight: bold;
}

.md-add .highlight .nn {
  color: #555;
}

.md-add .highlight .nt {
  color: #000080;
}

.md-add .highlight .err {
  color: #a61717;
  background-color: #e3d2d2;
}

.md-add .highlight .gd {
  color: #000;
  background-color: #fdd;
}

.md-add .highlight .gd .x {
  color: #000;
  background-color: #faa;
}

.md-add .highlight .ge {
  font-style: italic;
}

.md-add .highlight .gr {
  color: #aa0000;
}

.md-add .highlight .gh {
  color: #999;
}

.md-add .highlight .gi {
  color: #000;
  background-color: #dfd;
}

.md-add .highlight .gi .x {
  color: #000;
  background-color: #afa;
}

.md-add .highlight .go {
  color: #888;
}

.md-add .highlight .gp {
  color: #555;
}

.md-add .highlight .gs {
  font-weight: bold;
}

.md-add .highlight .gu {
  color: #800080;
  font-weight: bold;
}

.md-add .highlight .gt {
  color: #aa0000;
}

.md-add .highlight .ow {
  font-weight: bold;
}

.md-add .highlight .w {
  color: #bbb;
}

.md-add .highlight .sr {
  color: #017936;
}

.md-add .highlight .ss {
  color: #8b467f;
}

.md-add .highlight .bp {
  color: #999;
}

.md-add .highlight .gc {
  color: #999;
  background-color: #EAF2F5;
}

.md-add kbd {
  background-color: #e7e7e7;
  background-image: -webkit-linear-gradient(#fefefe, #e7e7e7);
  background-image: linear-gradient(#fefefe, #e7e7e7);
  background-repeat: repeat-x;
  display: inline-block;
  padding: 3px 5px;
  font: 11px Consolas, "Liberation Mono", Menlo, Courier, monospace;
  line-height: 10px;
  color: #000;
  border: 1px solid #cfcfcf;
  border-radius: 2px;
}

.md-add .highlight .pl-coc,
.md-add .highlight .pl-entm,
.md-add .highlight .pl-eoa,
.md-add .highlight .pl-mai .pl-sf,
.md-add .highlight .pl-pdv,
.md-add .highlight .pl-sc,
.md-add .highlight .pl-sr,
.md-add .highlight .pl-v,
.md-add .highlight .pl-vpf {
  color: #0086b3;
}

.md-add .highlight .pl-eoac,
.md-add .highlight .pl-mdht,
.md-add .highlight .pl-mi1,
.md-add .highlight .pl-mri,
.md-add .highlight .pl-va,
.md-add .highlight .pl-vpu {
  color: #008080;
}

.md-add .highlight .pl-c,
.md-add .highlight .pl-pdc {
  color: #b4b7b4;
  font-style: italic;
}

.md-add .highlight .pl-k,
.md-add .highlight .pl-ko,
.md-add .highlight .pl-kolp,
.md-add .highlight .pl-mc,
.md-add .highlight .pl-mr,
.md-add .highlight .pl-ms,
.md-add .highlight .pl-s,
.md-add .highlight .pl-sok,
.md-add .highlight .pl-st {
  color: #6e5494;
}

.md-add .highlight .pl-ef,
.md-add .highlight .pl-enf,
.md-add .highlight .pl-enm,
.md-add .highlight .pl-entc,
.md-add .highlight .pl-eoi,
.md-add .highlight .pl-sf,
.md-add .highlight .pl-smc {
  color: #d12089;
}

.md-add .highlight .pl-ens,
.md-add .highlight .pl-eoai,
.md-add .highlight .pl-kos,
.md-add .highlight .pl-mh .pl-pdh,
.md-add .highlight .pl-mp,
.md-add .highlight .pl-pde,
.md-add .highlight .pl-stp {
  color: #458;
}

.md-add .highlight .pl-enti {
  color: #d12089;
  font-weight: bold;
}

.md-add .highlight .pl-cce,
.md-add .highlight .pl-enc,
.md-add .highlight .pl-kou,
.md-add .highlight .pl-mq {
  color: #f93;
}

.md-add .highlight .pl-mp1 .pl-sf {
  color: #458;
  font-weight: bold;
}

.md-add .highlight .pl-cos,
.md-add .highlight .pl-ent,
.md-add .highlight .pl-md,
.md-add .highlight .pl-mdhf,
.md-add .highlight .pl-ml,
.md-add .highlight .pl-pdc1,
.md-add .highlight .pl-pds,
.md-add .highlight .pl-s1,
.md-add .highlight .pl-scp,
.md-add .highlight .pl-sol {
  color: #df5000;
}

.md-add .highlight .pl-c1,
.md-add .highlight .pl-cn,
.md-add .highlight .pl-pse,
.md-add .highlight .pl-pse .pl-s2,
.md-add .highlight .pl-vi {
  color: #a31515;
}

.md-add .highlight .pl-mb,
.md-add .highlight .pl-pdb {
  color: #df5000;
  font-weight: bold;
}

.md-add .highlight .pl-mi,
.md-add .highlight .pl-pdi {
  color: #6e5494;
  font-style: italic;
}

.md-add .highlight .pl-ms1 {
  background-color: #f5f5f5;
}

.md-add .highlight .pl-mdh,
.md-add .highlight .pl-mdi {
  font-weight: bold;
}

.md-add .highlight .pl-mdr {
  color: #0086b3;
  font-weight: bold;
}

.md-add .highlight .pl-s2 {
  color: #333;
}

.md-add .highlight .pl-ii {
  background-color: #df5000;
  color: #fff;
}

.md-add .highlight .pl-ib {
  background-color: #f93;
}

.md-add .highlight .pl-id {
  background-color: #a31515;
  color: #fff;
}

.md-add .highlight .pl-iu {
  background-color: #b4b7b4;
}

.md-add .highlight .pl-mo {
  color: #969896;
}

.md-add .task-list-item {
  list-style-type: none;
}

.md-add .task-list-item+.task-list-item {
  margin-top: 3px;
}

.md-add .task-list-item input {
  float: left;
  margin: 0.3em 0 0.25em -1.6em;
  vertical-align: middle;
}

app.html

<!doctype html>
<html lang="kr">
<head>
    <meta charset="UTF-8">
    <title>앱런처</title>
    <link rel="stylesheet" href="css/github_custom.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, target-densitydpi=medium-dpi">
</head>
<body>
<iframe name="common_frame" id="common_frame" src="about:blank" style="display:none; width:0;height:0;"></iframe>
<div class="markdown-wrap"><div class="md-add">

    <a href="/?app=C:\Program Files\cmder\Cmder.exe" target="common_frame">CMder 실행</a>
    <a href="/?app=C:\Windows\System32\notepad.exe" target="common_frame">메모장 실행</a>
    <a href="/?app=C:\Windows\System32\calc.exe" target="common_frame">계산기 실행</a>
    <a href="/?app=C:\Program Files\Oracle\VirtualBox\VirtualBox.exe" target="common_frame">VBOX 실행</a>
    <a href="/?app=C:\Program Files (x86)\Microsoft Office\Office14\EXCEL.EXE" target="common_frame">엑셀 실행</a>
    <a href="/?app=C:\Program Files (x86)\EditPlus 3\editplus.exe target="common_frame">에디트플러스 실행</a>
    <a href="/?app=C:\Program Files\Adobe\Adobe Photoshop CS5 (64 Bit)\Photoshop.exe" target="common_frame">포토샵</a>

</div></div>
</body>
</html>

app.js

var express = require('express');
var app = express();
var http = require('http').Server(app);
var url = require('url');
var fs = require('fs');
var exec = require('child_process').exec;
var port = 7000; // 포트

app.use("/", express.static(__dirname + '/'));
app.get('/', function(req, res){

    fs.readFile('app.html', function (error, data) {
        res.end(data);
    });

    var url_parts = url.parse(req.url, true);
    var query = url_parts.query;
    if(query.app) {

        var pr = query.app;
        AppRun('"'+pr+'"'); // 공백이 포함된 경로일경우 처리 추가
    }
});
http.listen(port, function(){

    console.log('localhost:'+port+' server is ready!!');
});



// 프로그램 실행
function AppRun(pg) {

    exec(pg, function (error, stdout, stderr) {  console.log(stdout); });
    console.log(pg+' is run!');
}


[NodeJS] 크롤링을 활용한 스크랩(DB저장).zip


0 Comments
댓글쓰기 폼