实验一的命令代码

2023-05-16

实验一

dcbuild 下载容器所需的image镜像,如果已经有了,就跳过

dcup 即docker-compose up 安装容器并启动

cd Labsetup1

1-1

vi test1.py 写一个python程序

chmod a+x test1.py 添加执行权限

sudo python3 test1.py 用root权限运行

ping 10.0.2.4 ping任意一个IP

#test1.py
#对于每个捕获的数据包,函数print pkt()将被调用;此函数将打印出有关数据包的一些信息。
#!/usr/bin/python
from scapy.all import *

def print_pkt(pkt):
    pkt.show()

pkt = sniff(filter="icmp",prn=print_pkt)

1-2

vi test2.py

chmod a+x test2.py

vi send2.py

chmod a+x send2.py

sudo python3 test2.py

sudo python3 send2.py

#test2.py
#只捕捉来自特定IP的TCP数据包	1
#!/usr/bin/python3
from scapy.all import *

def print_pkt(pkt):
    return pkt.summary()

pkt = sniff(filter="tcp and src host 10.0.2.4",prn=print_pkt)
print(pkt)


#发送数据包的代码 send2.py
#!/usr/bin/python3
from scapy.all import *
ip = IP()
ip.src = "10.0.2.4"
ip.dst = "10.0.2.15"
tcp = TCP() 
send(ip/tcp)
# 只捕捉ICMP数据包	2
#!/usr/bin/python3  
from scapy.all import *  

def print_pkt(pkt):  
    return pkt.summary()  
	  
pkt = sniff(filter="icmp",prn=print_pkt)  
print(pkt)  
# 捕获来自一个特定的子网的数据包,这里使用的子网为128.230.0.0/16	3  
#!/usr/bin/python3
from scapy.all import *  

def print_pkt(pkt):  
	return pkt.summary()  

pkt = sniff(filter="net 128.230.0.0/16",prn=print_pkt)  
print(pkt)  


# 发送数据包的代码  
#!/usr/bin/python3  
from scapy.all import *  

ip = IP()  
ip.src = "10.0.2.15"  
ip.dst = "128.230.0.1"  
tcp = TCP()   
send(ip/tcp)  
ip.src = "128.230.0.1"  
ip.dst = "10.0.2.15"  
send(ip/tcp) 

1-3

vi test3.py

chmod a+x test3.py

sudo python3 test3.py

#test3.py
#!/usr/bin/python3  
from scapy.all import *

ip = IP()
ip.src = "192.168.31.33" #虚假IP,真实IP是192.168.31.245  
ip.dst = "192.168.31.31" #是kali的IP  
icmp = ICMP()
send(ip/icmp)

1-4

vi test4.py

chmod a+x test4.py

sudo python3 test4.py

ping 1.2.3.4

#test4.py 
#A机器发送请求,B机器伪造响应

#!/usr/ bin/env python3
from scapy.all import*
##in sniff I do the exactly way until now
##in spoofing I cheak if the icmp packet is requst
##if it is I change only the icmp type to 0
##-reply and chnge the source and destination
def spoofing(pkt):
    if pkt[ICMP].type==8:
        dst=pkt[IP].dst
        src=pkt[IP].src
        ihll=pkt[IP].ihl

        idd=pkt[ICMP].id
        seqq=pkt[ICMP].seq
        load=pkt[Raw].load

        a=IP(src=dst,dst=src,ihl=ihll)
        b=ICMP(type=0,id=idd,seq=seqq)
        c=load
        ans=(a/b/c)
        send(ans)

pkt=sniff(filter="icmp",prn=spoofing)

1-5

5-1

vi test-c1.c

gcc -o test-c1 test-c1.c -lpcap

sudo ./test-c1

ping baidu.com

#include <pcap.h>
#include <stdio.h>
#include <arpa/inet.h>

/* Ethernet header */
struct ethheader {
  u_char  ether_dhost[6]; /* destination host address */
  u_char  ether_shost[6]; /* source host address */
  u_short ether_type;     /* protocol type (IP, ARP, RARP, etc) */
};

/* IP Header */
struct ipheader {
  unsigned char      iph_ihl:4, //IP header length
                     iph_ver:4; //IP version
  unsigned char      iph_tos; //Type of service
  unsigned short int iph_len; //IP Packet length (data + header)
  unsigned short int iph_ident; //Identification
  unsigned short int iph_flag:3, //Fragmentation flags
                     iph_offset:13; //Flags offset
  unsigned char      iph_ttl; //Time to Live
  unsigned char      iph_protocol; //Protocol type
  unsigned short int iph_chksum; //IP datagram checksum
  struct  in_addr    iph_sourceip; //Source IP address
  struct  in_addr    iph_destip;   //Destination IP address
};

void got_packet(u_char *args, const struct pcap_pkthdr *header,
                              const u_char *packet)
{
  struct ethheader *eth = (struct ethheader *)packet;

  if (ntohs(eth->ether_type) == 0x0800) { // 0x0800 is IP type
    struct ipheader * ip = (struct ipheader *)
                           (packet + sizeof(struct ethheader)); 

    printf("       From: %s\n", inet_ntoa(ip->iph_sourceip));   
    printf("         To: %s\n", inet_ntoa(ip->iph_destip));    

    /* determine protocol */
    switch(ip->iph_protocol) {                                 
        case IPPROTO_TCP:
            printf("   Protocol: TCP\n\n");
            return;
        case IPPROTO_UDP:
            printf("   Protocol: UDP\n\n");
            return;
        case IPPROTO_ICMP:
            printf("   Protocol: ICMP\n\n");
            return;
        default:
            printf("   Protocol: others\n\n");
            return;
    }
  }
}

int main()
{
  pcap_t *handle;
  char errbuf[PCAP_ERRBUF_SIZE];
  struct bpf_program fp;
  char filter_exp[] = "ip proto icmp";
  bpf_u_int32 net;

  // Step 1: Open live pcap session on NIC with name enp0s3
  handle = pcap_open_live("enp0s3", BUFSIZ, 1, 1000, errbuf);
  printf("listening on network card, ret: %p...\n", handle);

  // Step 2: Compile filter_exp into BPF psuedo-code
  printf("try to compile filter...\n");
  pcap_compile(handle, &fp, filter_exp, 0, net);
  printf("try to set filter...\n");
  pcap_setfilter(handle, &fp);

  // Step 3: Capture packets
  printf("start to sniff...\n");
  pcap_loop(handle, -1, got_packet, NULL);

  pcap_close(handle);   //Close the handle
  return 0;
}
5-2

vi test-c2.c

gcc -o test-c2 test-c2.c -lpcap

sudo ./test-c2

#include <pcap.h>
#include <stdio.h>
#include <arpa/inet.h>

/* Ethernet header */
struct ethheader {
  u_char  ether_dhost[6]; /* destination host address */
  u_char  ether_shost[6]; /* source host address */
  u_short ether_type;     /* protocol type (IP, ARP, RARP, etc) */
};

/* IP Header */
struct ipheader {
  unsigned char      iph_ihl:4, //IP header length
                     iph_ver:4; //IP version
  unsigned char      iph_tos; //Type of service
  unsigned short int iph_len; //IP Packet length (data + header)
  unsigned short int iph_ident; //Identification
  unsigned short int iph_flag:3, //Fragmentation flags
                     iph_offset:13; //Flags offset
  unsigned char      iph_ttl; //Time to Live
  unsigned char      iph_protocol; //Protocol type
  unsigned short int iph_chksum; //IP datagram checksum
  struct  in_addr    iph_sourceip; //Source IP address
  struct  in_addr    iph_destip;   //Destination IP address
};

void got_packet(u_char *args, const struct pcap_pkthdr *header,
                              const u_char *packet)
{
  struct ethheader *eth = (struct ethheader *)packet;

  if (ntohs(eth->ether_type) == 0x0800) { // 0x0800 is IP type
    struct ipheader * ip = (struct ipheader *)
                           (packet + sizeof(struct ethheader)); 

    printf("       From: %s\n", inet_ntoa(ip->iph_sourceip));   
    printf("         To: %s\n", inet_ntoa(ip->iph_destip));    

    /* determine protocol */
    switch(ip->iph_protocol) {                                 
        case IPPROTO_TCP:
            printf("   Protocol: TCP\n\n");
            return;
        case IPPROTO_UDP:
            printf("   Protocol: UDP\n\n");
            return;
        case IPPROTO_ICMP:
            printf("   Protocol: ICMP\n\n");
            return;
        default:
            printf("   Protocol: others\n\n");
            return;
    }
  }
}

int main()
{
  pcap_t *handle;
  char errbuf[PCAP_ERRBUF_SIZE];
  struct bpf_program fp;
  char filter_exp[] = "icmp and src host 192.168.31.31 and dst host 192.168.31.245";
  bpf_u_int32 net;

  // Step 1: Open live pcap session on NIC with name enp0s3
  handle = pcap_open_live("enp0s3", BUFSIZ, 1, 1000, errbuf);
  printf("listening on network card, ret: %p...\n", handle);

  // Step 2: Compile filter_exp into BPF psuedo-code
  printf("try to compile filter...\n");
  pcap_compile(handle, &fp, filter_exp, 0, net);
  printf("try to set filter...\n");
  pcap_setfilter(handle, &fp);

  // Step 3: Capture packets
  printf("start to sniff...\n");
  pcap_loop(handle, -1, got_packet, NULL);

  pcap_close(handle);   //Close the handle
  return 0;
}
5-3

vi myheader.h checksum.c spoof.c

vi udp.c

gcc -o udp udp.c spoof.c -lpcap

sudo ./udp

vi icmp.c

gcc -o icmp icmp.c spoof.c checksum.c -lpcap

sudo ./icmp

myheader.h
/* Ethernet header */
struct ethheader {
    u_char  ether_dhost[6];    /* destination host address */
    u_char  ether_shost[6];    /* source host address */
    u_short ether_type;                     /* IP? ARP? RARP? etc */
};

/* IP Header */
struct ipheader {
  unsigned char      iph_ihl:4, //IP header length
                     iph_ver:4; //IP version
  unsigned char      iph_tos; //Type of service
  unsigned short int iph_len; //IP Packet length (data + header)
  unsigned short int iph_ident; //Identification
  unsigned short int iph_flag:3, //Fragmentation flags
                     iph_offset:13; //Flags offset
  unsigned char      iph_ttl; //Time to Live
  unsigned char      iph_protocol; //Protocol type
  unsigned short int iph_chksum; //IP datagram checksum
  struct  in_addr    iph_sourceip; //Source IP address
  struct  in_addr    iph_destip;   //Destination IP address
};

/* ICMP Header  */
struct icmpheader {
  unsigned char icmp_type; // ICMP message type
  unsigned char icmp_code; // Error code
  unsigned short int icmp_chksum; //Checksum for ICMP Header and data
  unsigned short int icmp_id;     //Used for identifying request
  unsigned short int icmp_seq;    //Sequence number
};

/* UDP Header */
struct udpheader
{
  u_int16_t udp_sport;           /* source port */
  u_int16_t udp_dport;           /* destination port */
  u_int16_t udp_ulen;            /* udp length */
  u_int16_t udp_sum;             /* udp checksum */
};

/* TCP Header */
struct tcpheader {
    u_short tcp_sport;               /* source port */
    u_short tcp_dport;               /* destination port */
    u_int   tcp_seq;                 /* sequence number */
    u_int   tcp_ack;                 /* acknowledgement number */
    u_char  tcp_offx2;               /* data offset, rsvd */
#define TH_OFF(th)      (((th)->tcp_offx2 & 0xf0) >> 4)
    u_char  tcp_flags;
#define TH_FIN  0x01
#define TH_SYN  0x02
#define TH_RST  0x04
#define TH_PUSH 0x08
#define TH_ACK  0x10
#define TH_URG  0x20
#define TH_ECE  0x40
#define TH_CWR  0x80
#define TH_FLAGS        (TH_FIN|TH_SYN|TH_RST|TH_ACK|TH_URG|TH_ECE|TH_CWR)
    u_short tcp_win;                 /* window */
    u_short tcp_sum;                 /* checksum */
    u_short tcp_urp;                 /* urgent pointer */
};

/* Psuedo TCP header */
struct pseudo_tcp
{
        unsigned saddr, daddr;
        unsigned char mbz;
        unsigned char ptcl;
        unsigned short tcpl;
        struct tcpheader tcp;
        char payload[1500];
};
checksum.c
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <arpa/inet.h>

#include "myheader.h"


unsigned short in_cksum (unsigned short *buf, int length)
{
   unsigned short *w = buf;
   int nleft = length;
   int sum = 0;
   unsigned short temp=0;

   /*
    * The algorithm uses a 32 bit accumulator (sum), adds
    * sequential 16 bit words to it, and at the end, folds back all
    * the carry bits from the top 16 bits into the lower 16 bits.
    */
   while (nleft > 1)  {
       sum += *w++;
       nleft -= 2;
   }

   /* treat the odd byte at the end, if any */
   if (nleft == 1) {
        *(u_char *)(&temp) = *(u_char *)w ;
        sum += temp;
   }

   /* add back carry outs from top 16 bits to low 16 bits */
   sum = (sum >> 16) + (sum & 0xffff);  // add hi 16 to low 16
   sum += (sum >> 16);                  // add carry
   return (unsigned short)(~sum);
}

/****************************************************************
  TCP checksum is calculated on the pseudo header, which includes
  the TCP header and data, plus some part of the IP header.
  Therefore, we need to construct the pseudo header first.
*****************************************************************/


unsigned short calculate_tcp_checksum(struct ipheader *ip)
{
   struct tcpheader *tcp = (struct tcpheader *)((u_char *)ip +
                            sizeof(struct ipheader));

   int tcp_len = ntohs(ip->iph_len) - sizeof(struct ipheader);

   /* pseudo tcp header for the checksum computation */
   struct pseudo_tcp p_tcp;
   memset(&p_tcp, 0x0, sizeof(struct pseudo_tcp));

   p_tcp.saddr  = ip->iph_sourceip.s_addr;
   p_tcp.daddr  = ip->iph_destip.s_addr;
   p_tcp.mbz    = 0;
   p_tcp.ptcl   = IPPROTO_TCP;
   p_tcp.tcpl   = htons(tcp_len);
   memcpy(&p_tcp.tcp, tcp, tcp_len);

   return  (unsigned short) in_cksum((unsigned short *)&p_tcp,
                                     tcp_len + 12);
}
spoof.c
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <arpa/inet.h>

#include "myheader.h"

/*************************************************************
  Given an IP packet, send it out using a raw socket.
**************************************************************/
void send_raw_ip_packet(struct ipheader* ip)
{
    struct sockaddr_in dest_info;
    int enable = 1;

    // Step 1: Create a raw network socket.
    int sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
    printf("sock: %d\n", sock);

    // Step 2: Set socket option.
    setsockopt(sock, IPPROTO_IP, IP_HDRINCL,
                     &enable, sizeof(enable));

    // Step 3: Provide needed information about destination.
    dest_info.sin_family = AF_INET;
    dest_info.sin_addr = ip->iph_destip;

    // Step 4: Send the packet out.
    sendto(sock, ip, ntohs(ip->iph_len), 0,
           (struct sockaddr *)&dest_info, sizeof(dest_info));
    close(sock);
}

伪造UDP包
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <arpa/inet.h>

#include "myheader.h"

void   send_raw_ip_packet (struct ipheader* ip);

/******************************************************************
  Spoof a UDP packet using an arbitrary source IP Address and port
*******************************************************************/
int main() {
   char buffer[1500];

   memset(buffer, 0, 1500);
   struct ipheader *ip = (struct ipheader *) buffer;
   struct udpheader *udp = (struct udpheader *) (buffer +
                                          sizeof(struct ipheader));

   /*********************************************************
      Step 1: Fill in the UDP data field.
    ********************************************************/
   char *data = buffer + sizeof(struct ipheader) +
                         sizeof(struct udpheader);
   const char *msg = "Hello Server!\n";
   int data_len = strlen(msg);
   strncpy (data, msg, data_len);

   /*********************************************************
      Step 2: Fill in the UDP header.
    ********************************************************/
   udp->udp_sport = htons(12345);
   udp->udp_dport = htons(9090);
   udp->udp_ulen = htons(sizeof(struct udpheader) + data_len);
   udp->udp_sum =  0; /* Many OSes ignore this field, so we do not
                         calculate it. */

   /*********************************************************
      Step 3: Fill in the IP header.
    ********************************************************/
   ip->iph_ver = 4;
   ip->iph_ihl = 5;
   ip->iph_ttl = 20;
   ip->iph_sourceip.s_addr = inet_addr("1.1.1.1");
   ip->iph_destip.s_addr = inet_addr("8.8.8.8");
   ip->iph_protocol = IPPROTO_UDP; // The value is 17.
   ip->iph_len = htons(sizeof(struct ipheader) +
                       sizeof(struct udpheader) + data_len);

   /*********************************************************
      Step 4: Finally, send the spoofed packet
    ********************************************************/
   send_raw_ip_packet (ip);

   return 0;
}

伪造ICMP Echo请求
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/ip.h>
#include <arpa/inet.h>

#include "myheader.h"

unsigned short in_cksum (unsigned short *buf, int length);
void send_raw_ip_packet(struct ipheader* ip);

/******************************************************************
  Spoof an ICMP echo request using an arbitrary source IP Address
*******************************************************************/
int main() {
   char buffer[1500];

   memset(buffer, 0, 1500);

   /*********************************************************
      Step 1: Fill in the ICMP header.
    ********************************************************/
   struct icmpheader *icmp = (struct icmpheader *)
                             (buffer + sizeof(struct ipheader));
   icmp->icmp_type = 8; //ICMP Type: 8 is request, 0 is reply.

   // Calculate the checksum for integrity
   icmp->icmp_chksum = 0;
   icmp->icmp_chksum = in_cksum((unsigned short *)icmp,
                                 sizeof(struct icmpheader));

   /*********************************************************
      Step 2: Fill in the IP header.
    ********************************************************/
   struct ipheader *ip = (struct ipheader *) buffer;
   ip->iph_ver = 4;
   ip->iph_ihl = 5;
   ip->iph_ttl = 20;
   ip->iph_sourceip.s_addr = inet_addr("10.0.2.15");
   ip->iph_destip.s_addr = inet_addr("8.8.8.8");
   ip->iph_protocol = IPPROTO_ICMP;
   ip->iph_len = htons(sizeof(struct ipheader) +
                       sizeof(struct icmpheader));

   /*********************************************************
      Step 3: Finally, send the spoofed packet
    ********************************************************/
   send_raw_ip_packet (ip);

   return 0;
}

5-4

vi ss.c

gcc -o ss ss.c checksum.c spoof.c -lpcap

sudo ./ss

//ss.c
#include <pcap.h>
#include <stdio.h>
#include <arpa/inet.h>
#include "myheader.h"


void got_packet(u_char *args, const struct pcap_pkthdr *header,
                              const u_char *packet)
{
  struct ethheader *eth = (struct ethheader *)packet;

  if (ntohs(eth->ether_type) == 0x0800) { // 0x0800 is IP type
    struct ipheader * ip = (struct ipheader *)
                           (packet + sizeof(struct ethheader));

    printf("From: %s ", inet_ntoa(ip->iph_sourceip));   
    printf("To: %s ", inet_ntoa(ip->iph_destip));
    if (ip->iph_protocol == IPPROTO_ICMP)
        printf("protocal: ICMP\n");
    else
        printf("protocal: Others\n");
    
    struct icmpheader *icmp_pkt = (struct icmpheader *)(packet + sizeof(struct ethheader)
                                                               + sizeof(struct ipheader));

    if (ip->iph_protocol == IPPROTO_ICMP) {

        char buffer[1500];
        memset(buffer, 0, 1500);

        /*********************************************************
             Step 1: Fill in the ICMP header.
            ********************************************************/
        struct icmpheader *icmp = (struct icmpheader *)
                                    (buffer + sizeof(struct ipheader));
        icmp->icmp_type = 0; //ICMP Type: 8 is request, 0 is reply.
        icmp->icmp_code = 0;
        icmp->icmp_id   = icmp_pkt->icmp_id;
        icmp->icmp_seq  = icmp_pkt->icmp_seq;
        printf("icmp id: %d, seq: %d\n", ntohs(icmp_pkt->icmp_id), ntohs(icmp_pkt->icmp_seq));

        // Calculate the checksum for integrity
        icmp->icmp_chksum = 0;
        icmp->icmp_chksum = in_cksum((unsigned short *)icmp,
                                        sizeof(struct icmpheader));

        /*********************************************************
             Step 2: Fill in the IP header.
            ********************************************************/
        struct ipheader *ipp = (struct ipheader *) buffer;
        ipp->iph_ver = 4;
        ipp->iph_ihl = 5;
        ipp->iph_ttl = 64;
        ipp->iph_sourceip.s_addr = ip->iph_destip.s_addr;
        ipp->iph_destip.s_addr = ip->iph_sourceip.s_addr;
        ipp->iph_protocol = IPPROTO_ICMP;
        ipp->iph_len = htons(sizeof(struct ipheader) +
                            sizeof(struct icmpheader));
        printf("send tt source :%s\n", inet_ntoa(ipp->iph_sourceip));
        printf("send tt dest: %s\n", inet_ntoa(ipp->iph_destip));

        /*********************************************************
             Step 3: Finally, send the spoofed packet
            ********************************************************/
        // icmp_pkt->icmp_type = 0;
        // icmp_pkt->icmp_code = 0;
        // icmp->icmp_chksum = 0;
        // icmp->icmp_chksum = in_cksum((unsigned short *)icmp,
        //                                 sizeof(struct icmpheader));
        send_raw_ip_packet (ipp);

    }
  }
}

int main()
{
  pcap_t *handle;
  char errbuf[PCAP_ERRBUF_SIZE];
  struct bpf_program fp;
  char filter_exp[] = "icmp[icmptype]==icmp-echo";
  bpf_u_int32 net;

  // Step 1: Open live pcap session on NIC with name enp0s3
  handle = pcap_open_live("enp0s3", BUFSIZ, 1, 1000, errbuf);
  printf("listening on network card, ret: %p...\n", handle);

  // Step 2: Compile filter_exp into BPF psuedo-code
  printf("try to compile filter...\n");
  pcap_compile(handle, &fp, filter_exp, 0, net);
  printf("try to set filter...\n");
  pcap_setfilter(handle, &fp);

  // Step 3: Capture packets
  printf("start to sniff...\n");
  pcap_loop(handle, -1, got_packet, NULL);

  pcap_close(handle);   //Close the handle
  return 0;
}

附录

参考文章:

【网络攻防技术】实验九——嗅探与欺骗实验_whalien__52的博客-CSDN博客

网络攻防技术——嗅探与欺骗_啦啦啦啦啦啦啦噜噜的博客-CSDN博客_嗅探 欺骗

LAB 13 数据包嗅探和伪造_qq_39411845的博客-CSDN博客

数据包的嗅探与欺骗实验 | 望伊如西の博客 (dilidonglong.com)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

实验一的命令代码 的相关文章

  • nginx

    介绍 nginx Nginx是一款轻量级的Web服务器 反向代理服务器及电子邮件 xff08 IMAP POP3 xff09 代理服务器 其特点是占有内存少 xff0c 并发能力强 xff0c 在各大型互联网公司都有非常广泛的使用 nigi
  • SpringBoot基础

    SpringBootWeb快速入门 创建SpringBoot工程 xff08 需要联网 xff09 基于Spring官方骨架 xff0c 创建SpringBoot工程 基本信息描述完毕之后 xff0c 勾选web开发相关依赖 xff08 注
  • docker Hub-Node模式运行selenium grid4,经常遇到用例运行到60%-65%时无法继续运行

    问题描述 报错第一行 INTERNALERROR gt def worker internal error self node formatted error 报错中间错误内容详情 情况一 selenium common exception
  • Postman

    Postman是一款功能强大的网页调试与发送网页HTTP请求的Chrome插件 Postman原是Chrome浏览器的插件 xff0c 可以模拟浏览器向后端服务器发起任何形式 如 get post 的HTTP请求 使用Postman还可以在
  • MyBatis -- 1

    创建springboot工程 创建springboot工程 xff0c 并导入 mybatis的起步依赖 mysql的驱动包 配置MyBatis 在springboot项目中 xff0c 可以编写application properties
  • java.lang.ClassNotFoundException:javax.xml.bind.DatatypeConverter【解决办法】使用jwt时报错

    遇到的问题 java lang ClassNotFoundException javax xml bind DatatypeConverter 原因 xff1a 这有可能是因为SpringBoot项目结合jwt进行登录时出现的问题 xff0
  • 开发规范--REST、统一响应结果、开发流程

    开发规范 REST REST xff08 Representational State Transfer xff09 xff0c 表述性状态转换 xff0c 它是一种软件架构风格 传统URL风格如下 xff1a http localhost
  • Java-springboot中的常见的注解

    64 RestController RestController注解相当于 64 ResponseBody和 64 Controller合在一起使用 64 Controller xff1a 将当前修饰类注入ICO容器 xff0c 也有语义化
  • 文件上传前后端实现

    前端实现 span class token tag span class token tag span class token punctuation lt span form span span class token attr name
  • SpringBoot配置文件 -- 参数配置化

    常见配置文件格式对比 SpringBoot提供了多种属性配置方式 application properties server port 61 8080 server address 61 127 0 0 1 application yml
  • JWT令牌技术

    JWT令牌 全称 xff1a JOSN Web Token https jwt io 定义了一种简介的 自包含的格式 xff0c 用于在通信双方以JSON数据格式安全的传输信息 犹豫数字签名的存在 xff0c 这些信息是可靠的 通过base
  • 拦截器Interceptor

    Interceptor拦截器入门 介绍 什么是拦截器 xff1f 是一种动态拦截方法调用的机制 xff0c 类似于过滤器 拦截器是Spring框架中提供的 xff0c 用来动态拦截控制器方法的执行 拦截器的作用 xff1a 拦截请求 xff
  • 异常处理--全局异常处理器

    异常处理方案 出现异常之后 xff0c 三层依次向上抛出 xff0c 最后交给Spring框架处理 xff0c 返回一个JSON的错误信息 在三层构架项目中 xff0c 出现了异常 xff0c 可以用以下两种方式处理 方案一 xff1a 在
  • 简单理解位运算:位与&、位或|、位非~、异或^、左移<<、右移>>

    位运算 xff0c 顾名思义 xff0c 就是对字节中的每个位进行一位一位的运算 常见的运算符有 xff1a 位与 xff08 amp xff09 位或 xff08 xff09 位非 xff08 xff09 异或 xff08 xff09 左
  • bash 脚本字符串截取表达式详细说明

    在编写linux脚本时 xff0c 有时需要操作字符串 xff0c 从一个字符串中截取一段字符串 xff0c linux系统的bash脚本截取字符串的功能比较强 xff0c 表达式丰富 xff0c 时间长了容易忘记 xff0c 因此作此笔记
  • Springboot入门 -- AOP

    一 事务 1 回顾MySQL事务管理 事务的操作主要有三步 xff1a 开启事务 xff08 一组操作开始前 xff0c 开启事务 xff09 xff1a start transaction begin 提交事务 xff08 这组操作全部成
  • SpringBoot原理篇

    1 配置优先级 优先级一次为 xff1a application properties application yml application ymal 推荐使用yml 除了配置文件属性配置 xff0c 还支持Java系统属性和命令行参数的
  • maven私服配置说明

    私服配置说明 使用私服 xff0c 需要在maven的settings xml配置文件中 xff0c 做如下配置 xff1a 需要在 servers 标签中 xff0c 配置访问私服的个人凭证 访问的用户名和密码 span class to
  • Git基本使用

    1 Git快速入门 1 1 Git概述 Git是一个免费的 xff0c 开源的分布式版本控制系统 xff0c 可以快速高效地处理从小型或大型的各种项目 Git易于学习 xff0c 占用空间小 xff0c 性能快得惊人 官网 xff1a ht
  • MyBatisPlus

    1 简介 官网 xff1a https www baomidou com 2 相关依赖以及配置 2 1 pom引入依赖 span class token comment lt MyBatisPlus 启动器 gt span span cla

随机推荐

  • 使用STM32点亮LED

    多学多练 一 题目描述二 设计思路三 寄存器实现01 时钟配置02 模式设置03 代码编写04 创建工程文件 四 HAL库实现01 安装 STM32CubeMX02 安装HAL库03 新建工程04 Keil仿真调试 五 硬件连接六 逻辑仿真
  • C语言数据结构中利用栈和队列实现回文的判断

    数据结构中栈有着极为广大的运用 xff0c 其操作特点是FILO先进后出 队列的特点是FIFO先进先出 判断回文 xff0c 回文序列很好理解 xff0c 正反来看它都一样 那我们可以巧妙的利用栈和队列特点来判断回文 xff0c 存入进抽象
  • csp202112-1 序列查询 满分AC python

    nN 61 int x for x in input split n 61 nN 0 N 61 nN 1 list1 61 0 43 int x for x in input split if int x lt N 43 N num 61
  • isPrime()函数:判断素数,构造素数表

    素数函数isPrime xff08 素数 xff1a 指在大于1的自然数中 xff0c 除了1和它自身外 xff0c 不能被其他自然数整除的数 xff09 方法一 span class token keyword int span span
  • gets()函数

    gets 函数 1 描述 C 库函数 char gets char str 从标准输入 stdin 读取一行 xff0c 并把它存储在 str 所指向的字符串中 当读取到换行符时 xff0c 或者到达文件末尾时 xff0c 它会停止 xff
  • win11系统新版edge不兼容网银如何解决【解决办法】

    由于目前国内的网银都是基于IE浏览器进行开发的 xff0c 由于微软推行Edge xff0c Win11把IE砍掉后 xff0c 会将IE的链接强制跳转到Edge上 xff0c 很多网银无法调用 xff0c 对于需要使用Web网银的用户来说
  • 如何判断输入的字符是小写字母、大写字母还是数字?

    一 比较判断 计算机中字符都有自己的ASCII码 xff0c 并且数字 xff0c 字母都有自己的范围 如下 xff1a 类型ASCII码数字0 948 57大写字母A Z65 90小写字母a z97 122 但是在编码时可能记不住ASCI
  • C语言· 实现各进制间的相互转换

    数制只是人用来计数的不同方法 xff0c 但他们所表示的量不会改变 下面我们试着用C语言来实现数制之间的转换 一 由十进制转换为其他进制 我们常用的更为熟悉的是十进制 xff0c 那我们就用十进制开始 xff08 下面用二进制举例 xff0
  • C语言——如何简单地实现四舍五入

    如何实现数的四舍五入 span class token macro property span class token directive keyword include span span class token string lt st
  • 菜鸡自学 Python 笔记(二)

    菜鸡自学 Python 笔记 xff08 二 xff09 五 xff0c 结构与语句1 选择结构 if 语句2 循环控制语句 xff08 1 xff09 while 语句 xff08 2 xff09 for 语句 xff08 3 xff09
  • 菜鸡自学 Python 笔记(三)

    菜鸡自学 Python 笔记 xff08 三 xff09 九 函数1 内置函数2 自定义函数3 带参数的函数4 函数的返回值 十 处理异常和错误1 异常捕捉2 抛出异常3 自定义异常 十一 类与对象1 创建类和实例对象2 属性的公有 私有3
  • 一篇文章学会 Python 正则表达式!

    菜鸡自学 Python 笔记 xff1a 正则表达式 一 简单理解二 re findall函数三 普通字符与元字符1 普通字符2 元字符 四 修饰符 xff08 可选标志 xff09 五 re sub函数六 re match函数七 re s
  • DOM型XSS

    gt DOM型XSS与之前两种在原理上有本质区别 xff0c 它的攻击代码并不需要服务器解析响应 xff0c 触发XSS靠的是浏览器端的DOM解析 客户端上的JavaScript脚本可以直接访问浏览器的DOM并修改页面的内容 在客户端直接输
  • 三大linux系统对比

    概述 xff1a centos作为服务器部署是第一选择 CentOS去除很多与服务器功能无关的应用 xff0c 系统简单但非常稳定 xff0c 命令行操作可以方便管理系统和应用 xff0c 丰富的帮助文档和社区的支持 ubuntu最佳的应用
  • SQL数据查询之单表查询

    目录 语句格式 选择表中的若干列 查询表中所有列 选择表中的若干元组 查询满足条件的元组 字符匹配 涉及空值的查询 多重条件查询 ORDRD BY子句 聚集函数 GROUP BY子句 语句格式 SELECT ALL DISTINCT lt
  • NVIDIA CUDA安装失败解决方法

    CUDA安装失败原因可能与显卡驱动安装有关 xff0c 之前安装的显卡驱动影响了cuda安装 xff0c 建议就是清除原本的显卡驱动安装 xff0c 自动重启 xff0c 再重新安装cuda 下载显卡驱动安装工具解压 百度网盘链接 xff1
  • Jenkins在Linux环境下的安装与配置,包含遇到的问题以及解决方法

    一 Jenkins简介 Jenkins是一个开源软件项目 xff0c 是基于Java开发的一种持续集成 xff08 CI xff09 工具 xff0c 用于解决持续重复的部署 监控工作 xff1b 它一个开放易用的软件平台 xff0c 大大
  • win10添加ubuntu的网络硬盘,实现远程操作ubuntu硬盘

    1 前言 在工作时候经常需要在本地windows10和另外一台ubuntu上实现数据共享 xff0c 如果使用远程工具会非常麻烦 xff0c 需要收发文件 既然在同一个局域网情况下 xff0c 那么有没有办法实现远程操作硬盘呢 xff0c
  • (1)数据包嗅探和欺骗-SEED Ubuntu 20.04

    数据包嗅探和欺骗 网络安全课程实验一 在做的时候参考了很多网上主要就是CSDN上的教程 xff08 感觉最近还是很忙 xff0c 所以等我有空想起来再来写这个教程 xff09 xff08 下面放一下我的实验报告部分 xff0c 里面有流程
  • 实验一的命令代码

    实验一 dcbuild 下载容器所需的image镜像 xff0c 如果已经有了 xff0c 就跳过 dcup 即docker compose up 安装容器并启动 cd Labsetup1 1 1 vi test1 py 写一个python