일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- MFA
- 앱스토어
- openssl
- git
- 애플
- SwiftUI
- appres
- otpkey
- Nodejs
- kmip
- SSL
- MSYS2
- FIDO2
- MYSQL
- 2FA
- Android
- SSH
- apple
- 안드로이드
- fido
- 앨범북
- OSX
- 앱리소스
- 인증
- SWIFT
- css
- WebAuthn
- Xcode
- albumbook
- OTP
- Today
- Total
목록개발 플랫폼 및 언어 (340)
인디노트
#include #include #include #include #include #include #include #include #include #define MAX_BUF_LEN 2048 int main(int argc, char *argv[]) { int sockfd, n; char buffer[MAX_BUF_LEN]; struct sockaddr_in servaddr, cliaddr; socklen_t len = sizeof(cliaddr); // 소켓 생성 if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { perror("socket creation failed"); exit(EXIT_FAILURE); } // 소켓 옵션 설정 int reuse = 1; ..
#include #include #include #include #include #include #include #include int main() { int sock_fd; struct sockaddr_ll dest_addr; char buffer[ETH_FRAME_LEN]; unsigned char dest_mac[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; // Broadcast address // Create a PF_PACKET socket sock_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sock_fd < 0) { perror("socket"); return 1; } // Set the destinati..
#include #include #include #include #include #include #include #include #include #include #define ETH_FRAME_LEN 1518 int main() { int sockfd_in = 0, sockfd_out = 0, ret = 0; char buffer[ETH_FRAME_LEN] = {0}; struct sockaddr_ll dest = {0}; // create socket for eth0 sockfd_in = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sockfd_in == -1) { perror("socket"); exit(EXIT_FAILURE); } // bind soc..
#include #include #include #include #include #include #include #include #include #define ETH_HDRLEN 14 int main() { int sockfd = 0, ret = 0; char buffer[ETH_FRAME_LEN] = {0}; struct ethhdr *eth = NULL; struct sockaddr_in dest = {0}; // create raw socket sockfd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sockfd == -1) { perror("socket"); exit(EXIT_FAILURE); } // set destination address m..
#include #include #include #include #include #include void process_packet(unsigned char *buffer, int size); int main() { int sock_raw; int tcp_count = 0; struct sockaddr_in source, dest; unsigned char *buffer = (unsigned char*)malloc(65536); sock_raw = socket(AF_INET, SOCK_RAW, IPPROTO_TCP); if (sock_raw < 0) { printf("Error creating socket. Exiting...\n"); return 1; } while (1) { struct sockadd..
#include #include #include #include #include #include #include #include #include #include #include #include #define TIME_LOOP_WAIT 200000 // 200ms #define COUNT_CHECK_LOOP 5 #define SIZE_ICMP_PACKET 64 using namespace std; struct ICMP_PACKET { struct icmphdr hdr; char msg[SIZE_ICMP_PACKET - sizeof(struct icmphdr)]; } typedef ICMP_PACKET_t; /* functions */ unsigned short checksum(void* _data, int..
#include #include #include #include #include #include #include #define SERVER_IP "127.0.0.1" // 서버 IP 주소 #define SERVER_PORT 12345 // 서버 포트 번호 #define BUF_SIZE 1024 // 버퍼 크기 int main(int argc, char *argv[]) { int sock; struct sockaddr_in serv_addr; char buffer[BUF_SIZE]; int len, msglen; // 소켓 생성 sock = socket(AF_INET, SOCK_STREAM, 0); if (sock == -1) { perror("socket"); exit(1); } // 서버 주소 설정 m..
#include #include #include #include #include #include #include #define SERVER_IP "127.0.0.1" // 서버 IP 주소 #define SERVER_PORT 12345 // 서버 포트 번호 #define BUF_SIZE 1024 // 버퍼 크기 int main(int argc, char *argv[]) { int sock; struct sockaddr_in serv_addr; char buffer[BUF_SIZE]; int len, msglen; // 소켓 생성 sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { perror("socket"); exit(1); } // 서버 주소 설정 me..
Linux에서는 ioctl() 함수를 사용하여 네트워크 인터페이스의 정보를 가져올 수 있습니다. 이를 활용하여 자신의 Ethernet 카드의 MAC 주소를 가져올 수 있습니다. #include #include #include #include #include #include #include int main() { int sockfd = socket(AF_INET, SOCK_DGRAM, 0); if (sockfd < 0) { perror("Failed to create socket"); return 1; } // 인터페이스 이름 설정 char ifname[] = "eth0"; // 인터페이스 정보 구조체 생성 struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy..
C 코드로 Ethernet을 통해 전송한 데이터를 수신할 때, 일반적으로 Ethernet 프레임의 헤더를 확인하여 데이터의 출처를 확인할 수 있습니다. Ethernet 프레임의 헤더는 전송된 데이터에 대한 중요한 정보를 포함하고 있으며, 이 중 하나는 MAC 주소입니다. MAC 주소는 Ethernet 카드에 할당된 고유한 식별자이며, 데이터를 보내는 컴퓨터의 MAC 주소와 수신하는 컴퓨터의 MAC 주소를 Ethernet 프레임의 헤더에서 확인할 수 있습니다. 따라서, 수신된 데이터의 Ethernet 프레임 헤더에서 출발지 MAC 주소와 목적지 MAC 주소를 비교하여, 데이터가 내가 보낸 것인지 여부를 확인할 수 있습니다. 다음은 C 코드에서 이를 구현하는 예시입니다. #include #include #i..