无法安装Scapy并且需要依赖性.我花了一些时间谷歌搜索解决方案,但所有'解决方案'似乎影响旧版本的Python,或根本不工作.
脚本:
#!/usr/bin/python
import threading
import Queue
import time
from scapy.all import *
class WorkerThread(threading.Thread) :
def __init__(self, queue, tid) :
threading.Thread.__init__(self)
self.queue = queue
self.tid = tid
print 'Worker: %d' %self.tid
def run(self) :
total_ports = 0
while True :
port = 0
try :
port = self.queue.get(timeout=1)
except Queue.Empty :
print 'Worker %d exiting. %d ports scanned' %(self.tid, total_ports)
return
#Scanning begins
ip = sys.argv[1]
response = sr1(IP(dst=ip)/TCP(dport=port, flags='S'), verbose=False, timeout=.2)
if response :
if response[TCP].flags == 18 …Run Code Online (Sandbox Code Playgroud) 我有一个小脚本,我试图在字符串中嵌入字符串变量以发送请求。我遇到的问题是,当我使用 f 字符串格式时,出现以下错误。
richard@kali:~/Dropbox/offsec/Code/5_Bassmaster$ ./bassmaster.py 192.168.1.101
Traceback (most recent call last):
File "./bassmaster.py", line 15, in <module>
json = f'{"requests": [{request_1}, {request_2}, {request_3}]}'
ValueError: Invalid format specifier
Run Code Online (Sandbox Code Playgroud)
这是我的代码。据我了解,它应该嵌入所述字符串,但我无法消除该错误。我已尝试使用此处^建议的角色,但它不能解决问题。
#!/usr/bin/python3
import requests,sys
if len(sys.argv) != 2:
print(f"(+) usage: {sys.argv[0]} <target>")
sys.exit(-1)
target = f"http://{sys.argv[1]}:8080/batch"
request_1 = '{"method":"get","path":"/profile"}'
request_2 = '{"method":"get","path":"/item"}'
request_3 = '{"method":"get","path":"/item/$1.id"}'
json = f'{"requests": [{request_1}, {request_2}, {request_3}]}'
r = requests.post(target, json)
print(r.text)
Run Code Online (Sandbox Code Playgroud) 我正在尝试调整现有的配置文件设置菜单,以便我可以预先确定某些字段,例如带有下拉选项的性别,而不是用户必须输入它们.现在的代码如下所示,
<%= form_for @profile, html: {multipart: true}, url: profile_path do |f| %>
<div class="col-md-6">
<div class="form-group">
<%= f.text_field :firstname, required: true, placeholder: 'Firstname', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.text_field :lastname, required: true, placeholder: 'Lastname', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.date_field :dob, required: true, placeholder: 'Date of Birth', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.text_field :contactnr, required: true, placeholder: 'Contact Number', class: 'form-control' %>
</div>
<div class="form-group">
<%= f.text_field :address1, required: true, placeholder: 'Address Line 1', …Run Code Online (Sandbox Code Playgroud) 我正在尝试rake在Rails 4.2中安装gem。这个gem似乎安装得很好,但是Rails尝试运行时失败了,说看不到rake-10.5.0。我正在Rubymine中进行开发,而我得到的错误也在下面,我的Gemfile也是如此。我曾尝试Gemfile.lock按照其他帖子的建议删除,但无济于事。
安慰:
~/Development/RubymineProjects/Revenant.tech ?
ls
Gemfile Rakefile config lib test
Gemfile.lock app config.ru log tmp
README.rdoc bin db public vendor
~/Development/RubymineProjects/Revenant.tech ?
gem install rack
Successfully installed rack-1.6.4
Parsing documentation for rack-1.6.4
Done installing documentation for rack after 2 seconds
1 gem installed
~/Development/RubymineProjects/Revenant.tech ?
bundle update rake
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.5.0
Using i18n 0.7.0
Using json …Run Code Online (Sandbox Code Playgroud) I have a React app that is set up to send an API request to a server to retrieve books that match the user's input.
The problem I have is that as soon as any query begins to be typed into the search field the app goes into a loop, sending hundreds of requests and is only stopped when the query is cleared from the search.
How can I limit it to one call per change in user query?
import …Run Code Online (Sandbox Code Playgroud) 我有一个脚本,它接受一个int[]数组,将其转换为一个列表,并删除已经出现至少2次的所有进一步的整数.我遇到的问题是,当它进入我检查每个整数出现次数的循环时,我陷入了循环.
编辑:"我遗漏的是,列表必须保持其原始顺序,以便从上到下删除多余的数字.抱歉,如果那些已经回答的人感到困惑!
我认为改变的数量occursintegerOccurrence将作为while循环的计数变化.
关于我在这里缺少什么的想法?除了任何可辨别的技能.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
public class Kata
{
public static void Main()
{
int[] arr = new int[] {1, 2, 1, 4, 5, 1, 2, 2, 2};
int occurrenceLimit = 2;
var intList = arr.ToList();
for (int i = 0; i < intList.Count; i++)
{
var occursintegerOccurrence = intList.Count(n => n == occurrenceLimit);
do
{
occursintegerOccurrence = intList.Count(n => n == occurrenceLimit);
foreach (var x in intList)
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个独立的 .NET Core 6.0 二进制文件,并将所有依赖项打包在一个.exe文件中。
我遇到的问题是,虽然二进制文件编译正常,但它依赖于位于 Release/Debug 文件夹中的 DLL。
我尝试过从命令行编译
dotnet publish --standalone
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,我只是遇到了类似的问题,加载更多 DLL,并且二进制文件本身大小相同,需要位于该文件夹中才能运行。
我正在寻找的东西是否可能,如果可以,如何实现?dotnet到目前为止,我已经尝试过 Visual Studio、 cli 和 Rider。
有许多旧的解决方案提到了诸如此类的解决方案,ilmerge但这似乎早已被弃用并且不再维护。
-- 为未来的我编辑:
最终的解决方案看起来像这样,感谢下面安德鲁的回答。
我的最终 project.csproj 文件看起来像这样基于MS Docs
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishSingleFile>true</PublishSingleFile>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
通过 Visual Studio GUI 发布或:
dotnet publish -c release -r win-x64
Run Code Online (Sandbox Code Playgroud) 我没有真正的使用正则表达式的经验,只是说.我想用以下格式从电子邮件地址中提取域名.
richardc@mydomain.com以便正则表达式返回:mydomain
如果可能的话,解释它如何/为什么有效!干杯
我正在写一个小程序作为课程的一部分作为秒表.我遇到的问题是,当我尝试编译时 Cannot convert from void to bool,我会Duration()在Program.cs课堂上学习我的方法.该方法应该返回TimeSpan
我无法看到它被设置的位置void.可能是C#运行时中较低级别的东西?不确定.
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Stopwatch
{
class Program
{
static void Main(string[] args)
{
var stopwatch = new StopWatchController();
stopwatch.Start();
stopwatch.Start(); // Second Start() method should throw an exception
stopwatch.Stop();
Console.WriteLine(stopwatch.Duration()); // Error appears here
}
}
}
Run Code Online (Sandbox Code Playgroud)
StopwatchController.cs
using System;
using System.Runtime.CompilerServices;
namespace Stopwatch
{
public class StopWatchController
{
private DateTime _startTime;
private DateTime _finishTime; …Run Code Online (Sandbox Code Playgroud) 我正在尝试(合法地)利用具有SQLi漏洞的MariaDb数据库。
我在这里发现了漏洞...
/?o=1&page=app
将o=*是脆弱的,并产生下列错误...
DEBUG INFO: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '5' or dest like '1'') LIMIT 10' at line 1
我正在使用Burp Suite,并采用了以下语法,该语法似乎更接近商标,但仍会产生语法错误。
我认为它离商标更近了,因为错误只会吐出我介绍的查询,而不是“额外”字段:'5' or dest like '1'') LIMIT 10'。
我假设这是原始查询的一部分,因为1它包含在内,当我使用其他随机字符串进行测试时,它仍然为真。
我从页面提示中知道的管理员密码哈希值是uid 1。
这个查询我缺少什么?
SELECT Password FROM mysql.user WHERE (uid = '1' or dest like '%')-- ') LIMIT 10
编辑:这是在Hack The Box上完成的,所以没有讨厌的非法事情发生。
我开始使用Java并尝试找到一种简洁的方法来重构下面的代码,以便我可以将firstName变量设置为字符串并在同一行中获取并将firstNameLength字符串长度设置为整数.
String firstName = "Boris";
int firstNameLength = firstName.length();
Run Code Online (Sandbox Code Playgroud)
我一直在尝试以下代码的变体,但无济于事!
int newAge = String firstName = "Boris".length();
Run Code Online (Sandbox Code Playgroud)