Я создаю инструмент с открытым исходным кодом (OSINT) в python. Я создал простой интерфейс для него, используя html и javascript. Но вывод не учитывает символ новой строки в сценарии python. Я уже пробовал использовать тег br в html. Но это не работает. Пожалуйста, предложите решение.
ОС Подробности - Кали Linux
![enter image description here](https://i.stack.imgur.com/MuMs9.png)
HTML КОД
<html lang = "en" >
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel = "stylesheet" href = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src = "https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
<style>
.container{
margin: 3rem;
}
.content {
width: 100%;
height:100%;
}
.content-item {
margin: 2rem;
right: 45px;
}
.form {
min-width: 50rem;
}
</style>
<script type = "text/javascript">
var app = angular.module('myApp', ['ngMaterial', 'ngMessages']).config(function ($mdThemingProvider) {
$mdThemingProvider.theme('default')
.primaryPalette('amber', {
'default': '400', // by default use shade 400 from the pink palette for primary intentions
'hue-1': '200', // use shade 100 for the <code>md-hue-1</code> class
'hue-2': '600', // use shade 600 for the <code>md-hue-2</code> class
'hue-3': 'A100'
})
.accentPalette('green', {
'default': '300'
})
.warnPalette('red', {
'default': '600'
});
});
app.controller("myCtrl", function($scope, $http)
{
$scope.sub = function()
{
//alert("called");
var input = $scope.input;
var file = "";
if ($scope.c1)
{
file = "ip";
}
else if ($scope.c3)
{
file = "tor"
}
else if ($scope.c6)
{
file = "wikipedia"
}
else if ($scope.c11)
{
file = "hashes"
}
else if ($scope.c14)
{
file = "pastebin"
}
$http.post('http://localhost:3000/myaction', {"input":input, "file":file}).then(function(response){
$scope.answer = response.data;
});
}
})
</script>
</head>
<body ng-app = "myApp" ng-controller="myCtrl" ng-cloak>
<md-toolbar class = "md-warn">
<div class = "md-toolbar-tools">
<h2 class = "md-flex">SENTRY</h2>
</div>
</md-toolbar>
<div class = "container" layout = "row" layout-align="left ">
<md-whiteframe class="md-whiteframe-5dp" class="content">
<div class="content-item">
<h2 class = "md-flex">INPUT</h2>
<form ng-submit="sub()" class="form" layout="column" >
<md-input-container>
<label>Scan Name</label>
<input name="name" id="name">
</md-input-container>
<md-input-container>
<label>Scan Input</label>
<input name="input" ng-model = "input" id="input">
</md-input-container>
<md-checkbox name="c1" id="c1" ng-model="c1">
<div class="row">
IP Information
</div>
</md-checkbox>
<md-checkbox>
<div clss="row">
IP Blacklist Check
</div>
</md-checkbox>
<md-checkbox name="c3" id="c3" ng-model="c3">
<div class="row">
Tor Exit Node Check
</div>
</md-checkbox>
<md-checkbox>
<div class="row">
Username Check
</div>
</md-checkbox>
<md-checkbox>
<div class="row">
Twitter Activity
</div>
</md-checkbox>
<md-checkbox name="c6" id="c6" ng-model="c6">
<div class="row">
Wikipedia Edits
</div>
</md-checkbox>
<md-checkbox>
<div class="row">
Domain Name Information
</div>
</md-checkbox>
<md-checkbox>
<div class="row">
Detailed Domain Name Information
</div>
</md-checkbox>
<md-checkbox>
<div class="row">
Domain Name's Email Adresses
</div>
</md-checkbox>
<md-checkbox>
<div class="row">
Domain Name's DNS Map
</div>
</md-checkbox>
<md-checkbox name="c11" id="c11" ng-model="c11">
<div class="row">
Hash Cracking
</div>
</md-checkbox>
<md-checkbox>
<div class="row">
Email Address Validity Check
</div>
</md-checkbox>
<md-checkbox>
<div class="row">
Email Address Leak Check
</div>
</md-checkbox>
<md-checkbox name="c14" id="c14" ng-model="c14">
<div class="row">
Email Address Pastebin Leak Check
</div>
</md-checkbox>
<md-button type="submit" class="md-warn md-raised">Run Scan</md-button>
</form>
</div>
</md-whiteframe>
<md-whiteframe class="md-whiteframe-5dp" class="content">
<div class="content-item">
<h2 class = "md-flex">OUTPUT</h2>
<p>{{answer}}</p>
</div>
</md-whiteframe>
</div>
</body>
</html>
JAVASCRIPT КОД
// import express JS module into app
// and creates its variable.
var express = require('express');
var http = require('http');
var bodyParser = require('body-parser');
var app = express();
var FileReader = require('filereader');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(express.static(__dirname + '/static'));
// Renders the index.html file where the frontend resides
app.get('/',function(req,res) {
// res.setHeader('Content-Type', 'text/html');
res.sendFile(__dirname + '/root.html');
});
// Defines the action to be performed after submit button is clicked in html
app.post('/myaction', function(req, res) {
//res.send('You sent the name "' + req.body.name + '".');
console.log(req.body);
callName(req, res);
});
// Creates a server which runs on port 3000 and
// can be accessed through localhost:3000
app.listen(3000, function() {
console.log('server running on port 3000');
})
// Function callName() is executed whenever it is called
function callName(req, res) {
// Use child_process.spawn method from
// child_process module and assign it
// to variable spawn
var spawn = require("child_process").spawn;
// Parameters passed in spawn -
// 1. type_of_script
// 2. list containing Path of the script
// and arguments for the script
if (req.body.file=="ip")
{
var process = spawn('python',["./ip.py", req.body.input]); // Here, any input which is sent to python file must be mentioned
}
else if(req.body.file=="tor")
{
var process = spawn('python',["./torcheck.py", req.body.input]);
}
else if(req.body.file=="wikipedia")
{
var process = spawn('python',["./wikipedia.py", req.body.input]);
}
else if(req.body.file=="hashes")
{
var process = spawn('python',["./hashes.py", req.body.input]);
}
else if(req.body.file=="pastebin")
{
var process = spawn('python',["./pastebin.py", req.body.input]);
}
// Takes stdout data from script which executed
// with arguments and send this data to res object
//process.stdout.setEncoding("utf8");
process.stdout.on('data', function(data) {
res.send(data.toString())
} )
}
// save code as start.js
PYTHON КОД
from requests import get
import os
import sys
domain = sys.argv[1]
url = "whois " + domain + " | sed -n '/The Registry/,/>>>/p'"
os.system(url)