RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-253991

NordeN's questions

Martin Hope
NordeN
Asked: 2025-02-16 00:48:43 +0000 UTC

如何在 markdown 中使 CMD 语法高亮?

  • 5

Markdown 代码块能够突出显示特定语言的语法。通过在三重引号后指定样式,例如:

PowerShell

'''

我特意放了不同类型的引号,如何在 cmd 窗口中突出显示语法?如果您选择“批处理”文件类型,Visual Studio Code 会突出显示这一点,但我已经尝试了所有方法,但都不起作用(我在 Obsidian 中工作)

markdown
  • 1 个回答
  • 30 Views
Martin Hope
NordeN
Asked: 2024-02-02 23:36:53 +0000 UTC

bash 脚本有关返回码检查的意外行为

  • 7

请告诉我。有一个实用程序在某种情况下返回代码 70。我处理这种情况的代码不起作用,我做错了什么?

kesl-control --start-task 1 &> /dev/null
if [[ $? == 0 ]]; then
    echo 1
elif [[ $? == 70 ]]; then
    echo 2
else
    echo 3
fi

理论上,如果返回码是 70,那么我的脚本应该输出2,但在这种情况下它总是输出3。我究竟做错了什么?

bash
  • 1 个回答
  • 20 Views
Martin Hope
NordeN
Asked: 2020-07-31 03:06:59 +0000 UTC

python中的正则表达式不能按预期工作[重复]

  • -1
这个问题已经在这里得到了回答:
正则表达式捕获的文本过多 1 个回答
2年前关闭。

帮助我理解为什么会这样,这里是代码:

import re

TEXT = r'''
local afp = require "afp"
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
local unpwdb = require "unpwdb"

-- we don't really need openssl here, but let's attempt to load it as a way
-- to simply prevent the script from running, in case we don't have it
local openssl = stdnse.silent_require("openssl")

description = [[
Performs password guessing against Apple Filing Protocol (AFP).
]]

---
-- @usage
-- nmap -p 548 --script afp-brute <host>
--
-- @output
-- PORT    STATE SERVICE
-- 548/tcp open  afp
-- | afp-brute:
-- |_  admin:KenSentMe => Valid credentials

-- Information on AFP implementations
--
-- Snow Leopard
-- ------------
-- - Delay 10 seconds for accounts with more than 5 incorrect login attempts (good)
-- - Instant response if password is successful
--
-- Netatalk
-- --------
-- - Netatalk responds with a "Parameter error" when the username is invalid
--

author = "Patrik Karlsson"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"intrusive", "brute"}


-- Version 0.3
-- Created 01/15/2010 - v0.1 - created by Patrik Karlsson <patrik@cqure.net>
-- Revised 03/09/2010 - v0.2 - changed so that passwords are iterated over users
--                           - this change makes better sense as guessing is slow
-- Revised 09/09/2011 - v0.3 - changed account status text to be more consistent with other *-brute scripts

portrule = shortport.port_or_service(548, "afp")

action = function( host, port )

  local result, response, status = {}, nil, nil
  local valid_accounts, found_users = {}, {}
  local helper
  local usernames, passwords

  status, usernames = unpwdb.usernames()
  if not status then return end

  status, passwords = unpwdb.passwords()
  if not status then return end

  for password in passwords do
    for username in usernames do
      if ( not(found_users[username]) ) then

        helper = afp.Helper:new()
        status, response = helper:OpenSession( host, port )

        if ( not(status) ) then
          stdnse.debug1("OpenSession failed")
          return
        end


        stdnse.debug1("Trying %s/%s ...", username, password)
        status, response = helper:Login( username, password )

        -- if the response is "Parameter error." we're dealing with Netatalk
        -- This basically means that the user account does not exist
        -- In this case, why bother continuing? Simply abort and thank Netatalk for the fish
        if response:match("Parameter error.") then
          stdnse.debug1("Netatalk told us the user does not exist! Thanks.")
          -- mark it as "found" to skip it
          found_users[username] = true
        end

        if status then
          -- Add credentials for other afp scripts to use
          if nmap.registry.afp == nil then
            nmap.registry.afp = {}
          end
          nmap.registry.afp[username]=password
          found_users[username] = true

          table.insert( valid_accounts, string.format("%s:%s => Valid credentials", username, password:len()>0 and password or "<empty>" ) )
          break
        end
        helper:CloseSession()
      end
    end
    usernames("reset")
  end

  local output = stdnse.format_output(true, valid_accounts)

  return output

end
'''

description_regex = re.compile(r'description = \[\[.*\]\]', flags=re.DOTALL)
categories_regex = re.compile(r'categories = \{.*\}', flags=re.DOTALL)

script_description = re.search(description_regex, TEXT)
print(script_description.group(0))
script_categories = re.search(categories_regex, TEXT)
print(script_categories.group(0))

为什么 script_categories 以模式后的所有文本结尾?但不是categories = {"intrusive", "brute"}它的意图?

python
  • 1 个回答
  • 10 Views
Martin Hope
NordeN
Asked: 2020-05-26 15:53:30 +0000 UTC

如何在一行中编写 Python 脚本?

  • 1

有一个代码:

import socket

s = socket.socket()
s.connect(('192.168.0.195', 6969))

with open('hello.txt', "rb") as f:
    buffer = f.read(4096)
    while buffer:
        s.sendall(buffer)
        buffer = f.read(4096)

s.close()

是否可以将它写在一行中(通过;),以便可以通过执行python -c '...'?

python
  • 3 个回答
  • 10 Views
Martin Hope
NordeN
Asked: 2020-04-11 20:04:12 +0000 UTC

格式化字符串时转换为 str

  • 1

该函数是否format()将所有参数隐式转换为str?

此代码引发错误:

a = 10
print('A: ' + a)

但是没有一个:

a = 10
print('A: {}'.format(a)

如果有一个隐式转换,那么它不是多余的吗?在最简单的情况下,当你可以不用format(), 来连接时,它会不会更好+?

python
  • 5 个回答
  • 10 Views
Martin Hope
NordeN
Asked: 2020-04-05 17:00:54 +0000 UTC

无法在python中关闭数据库连接

  • 0

有一个脚本,它的主要部分是:

try:
    con = sqlite3.connect('Posts.db')
    cur = con.cursor()
...
except:
...
except:

finally:
    cur.close()
    con.close()

事实是,在我的代码中,打开连接和游标后,会产生错误,无论是否发生错误,我都想关闭连接。

怎么安排最好?在每个例外中,我在错误 print 之后都有一个 raise SystemExit。如果我最后写:

cur.close()
con.close()

那么事情可能达不到他们的执行?是的,解释器抛出错误。NameError: name 'cur' is not defined

python
  • 1 个回答
  • 10 Views
Martin Hope
NordeN
Asked: 2020-08-15 13:01:49 +0000 UTC

带有 ctl 后缀的 Linux 实用程序

  • 1

我在哪里或如何在终端中看到它们?我只知道 sysctl、systemctl、hostnamectl、localectl 和 timedatectl,不知道是不是全部。

linux
  • 2 个回答
  • 10 Views
Martin Hope
NordeN
Asked: 2020-11-03 16:54:17 +0000 UTC

是否可以在 C# 中将多行 lambda 作为方法参数传递?

  • -1

大家好。有一个主窗体,在它 DataGridView 中,我想用我创建的流程中的数字填充它。是否可以将多个语句中的 lambda 作为参数传递给方法(在本例中为构造函数)?我知道您可以在构造函数之前声明一个委托并传递一个包含对该对象的引用的变量。在我看来它看起来更漂亮,但这个选项是错误的。

private void SetData(object number)
{
    DataTable.Invoke(new Action<int>(n =>
    {
        DataTable.RowCount = n;
        for (int i = 0; i < n; i++)
        {
            DataTable.Rows[i].Cells[0].Value = i.ToString();
            DataTable.Update();
        }
    };), (int)number);
}

private void StartButtonClick(object sender, EventArgs e)
{
    Thread thread = new Thread(SetData);
    thread.Start(10000);
}
c#
  • 1 个回答
  • 10 Views
Martin Hope
NordeN
Asked: 2020-07-27 03:14:33 +0000 UTC

Visual Studio 热键

  • 3

我遇到了一个问题,在 WPF 项目中,使用 XAML 编辑器处理窗口的一半和使用设计器处理窗口的一半是不方便的。我将显示设置为全屏,但是现在,为了从设计器切换到编辑器并返回,您需要不断地单击鼠标。

您可以从编辑器切换到构造器Shift+ F7。

有谁知道反向操作的热键?Ctrl++Alt转换0为代码,但您需要将其转换为 XAML。

c#
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5