找了好久才找到的
月度归档:2011年06月
微星 785GTM-E45 自制串口线
购入jlink 自制 转接线
晕菜到家了,买了jlink没买转换板,发的6410的版是2.0间距的10p的口,在淘宝上买板,这不是放假人家不发货,而且还没线卖,我要板没线还是用不了。一气之下,自己做了一条转换线。10p FC头,是以前买来做jtag线用的,20p fc头没有,用的dma33的ide线的头,拆了,锯开,打磨,用502粘上的,10p 2.54转2.0是用从老的磨托罗拉的BP机的板子上拆下来的单排母口做的,哈哈。接口定义如下,上图.留给有用的朋友
s3c_6410(亚嵌发的那个)
1 VDD_IO 电源 3.3V(输入)
2 VDD_IO 电源 3.3V(输入)
3 TRSTn TRSTn
4 nRESET nRESET
5 TDI TDI
6 TDO TDO
7 TMS TMS
8 GND 地
9 TCK TCK
10 GND 地
jlink v8 (20PIN)
1 vref
2 vcc(VTARGET)
3 TRST_N
5 TDI
7 TMS
9 TCK
11 RTCK
13 TDO
15 SRST_N
17 DBGRQ(Wiggler)
19 DBGACK(Wiggler)
other: GND
转换关系
jlink 20 -> 10pin
1 1 (1,2连在一起)
2 2 (1,2连在一起)
3 3
5 5
7 7
8 8
9 9
10 10
15 4
13 6
由于开发板的p1,p2本来就是连在一起的,所以1->1,2->2就行了
SEGGER J-Link Commander V4.26b ('?' for help)
Compiled May 20 2011 17:18:29
DLL version V4.26b, compiled May 20 2011 17:18:15
Firmware: J-Link ARM V8 compiled Apr 27 2011 20:42:35
Hardware: V8.00
S/N: 20100214
Feature(s): RDI,FlashDL,FlashBP,JFlash,GDBFull
VTarget = 3.248V
Info: TotalIRLen = 9, IRPrint = 0x0011
Found 2 JTAG devices, Total IRLen = 5:
#0 Id: 0x2B900F0F, IRLen: 04, IRPrint: 0x0, ARM ETB
#1 Id: 0x07B76F0F, IRLen: 05, IRPrint: 0x1, ARM1176 Core
ARM11 identified.
JTAG speed: 100 kHz
J-Link>
ARP 功击与抓包代码
上课的地方arp横行,总是上不去网。
研究了一下arp功击的代码。总用更高的频率来解决功击网关的问题,失败告终。
抓包
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <string.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
void print_arp(unsigned char *a,int len)
{
int i;
char ccc='1';
for(i=0;i<len;i++){
if(i==6 || i==12 || i==14 || i==16 || i==18 || i==19 || i==20 || i==22 || i==28 || i==32 || i==38 || i==42)
putchar('|');
if((i>=28 && i<=31) || (i>=38 && i<=41))
printf("%d.",a[i]);
else
printf("%02x",a[i]);
//fflush(stdout);
}
putchar('n');
}
void print_eth(unsigned char *a,int len)
{
int i;
for(i=0;i<len;i++){
printf("%02x",a[i]);
}
putchar('n');
}
int set_promisc(char *interface, int fd) {
struct ifreq ifr;
strcpy(ifr.ifr_name, interface);
if(ioctl(fd, SIOCGIFFLAGS, &ifr) == -1) {
perror("iotcl()");
return -1;
}
ifr.ifr_flags |= IFF_PROMISC;
if(ioctl(fd, SIOCSIFFLAGS, &ifr) == -1) {
perror("iotcl()");
return -1;
}
return 0;
}
int main(int argc, char **argv) {
int sock, n;
unsigned char buffer[2048];
unsigned char *iphead, *ethhead;
struct sockaddr_ll sll;
// if(argc != 3){
// printf("need interface name and protocol as argumentsn");
// return -1;
// }
if ( (sock=socket(PF_PACKET, SOCK_RAW,
htons(ETH_P_ARP)))<0) {
perror("socket");
exit(1);
}
sll.sll_family = PF_PACKET;
// sll.sll_ifindex = Get_IfaceIndex(sock,argv[1]); //通过此处传入网络设备接口
struct ifreq ifstruct;
strcpy(ifstruct.ifr_name, "eth0");
//sll.sll_protocol = htons(atoi(argv[2]));
sll.sll_protocol=htons(ETH_P_ARP);
if(bind(sock,(struct sockaddr *)(&sll),sizeof(sll))==-1)
{
printf("bind error:%s !n",strerror(errno));
return -1;
}
//int set_promisc(char *interface, int fd) {
if(set_promisc("eth0",sock) == -1)
{
printf("BLUE set promisc failed !n");
return -1;
}
while (1) {
printf("—–recive start—–n");
n = recvfrom(sock,buffer,2048,0,NULL,NULL);
printf("%d bytes readn",n);
printf("index:%dn",sll.sll_ifindex );
/* Check to see if the packet contains at least
* complete Ethernet (14), IP (20) and TCP/UDP
* (8) headers.
*/
if (n<42) {
perror("recvfrom():");
printf("Incomplete packet (errno is %d)n",
errno);
close(sock);
exit(0);
}
ethhead = buffer;
printf("Destination MAC address: "
"%02x:%02x:%02x:%02x:%02x:%02xn",
ethhead[0],ethhead[1],ethhead[2],
ethhead[3],ethhead[4],ethhead[5]);
printf("Source MAC address: "
"%02x:%02x:%02x:%02x:%02x:%02xn",
ethhead[6],ethhead[7],ethhead[8],
ethhead[9],ethhead[10],ethhead[11]);
printf("protocal:"
"0x%02x%02xn",ethhead[12],ethhead[13]);
iphead = buffer+14; /* Skip Ethernet header */
if (*iphead==0x45) { /* Double check for IPv4
* and no options present */
printf("Source host %d.%d.%d.%dn",
iphead[12],iphead[13],
iphead[14],iphead[15]);
printf("Dest host %d.%d.%d.%dn",
iphead[16],iphead[17],
iphead[18],iphead[19]);
printf("Source,Dest ports %d,%dn",
(iphead[20]<<8)+iphead[21],
(iphead[22]<<8)+iphead[23]);
printf("Layer-4 protocol %dn",iphead[9]);
}
//print_eth(1,buffer,512);
print_arp(ethhead,48);
// print_eth(ethhead,n);
}
}
功击
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <string.h>
#include <linux/if_packet.h>
#include <linux/if_ether.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
void print_eth(unsigned char *a,int len)
{
int i;
for(i=0;i<len;i++){
printf("%02x",a[i]);
}
putchar('n');
}
int set_promisc(char *interface, int fd) {
struct ifreq ifr;
strcpy(ifr.ifr_name, interface);
if(ioctl(fd, SIOCGIFFLAGS, &ifr) == -1) {
perror("iotcl()");
return -1;
}
ifr.ifr_flags |= IFF_PROMISC;
if(ioctl(fd, SIOCSIFFLAGS, &ifr) == -1) {
perror("iotcl()");
return -1;
}
return 0;
}
int main(int argc, char **argv){
int sock;
char SendBuffer[64];
char intfname[16];
struct sockaddr_ll dest;
struct sockaddr_ll sll;
memset(&dest,0,sizeof(dest));
memset(&sll,0,sizeof(sll));
strcpy(intfname,argv[1]);
dest.sll_family=AF_PACKET;
dest.sll_protocol=htons(ETH_P_ALL);
if ( (sock=socket(PF_PACKET, SOCK_RAW,
htons(ETH_P_ALL)))<0) {
perror("socket");
exit(1);
}
sll.sll_family = AF_PACKET;
// sll.sll_ifindex = Get_IfaceIndex(sock,intfname);
struct ifreq ifstruct;
strcpy(ifstruct.ifr_name, "eth0");
sll.sll_protocol = htons(ETH_P_ALL);
dest.sll_ifindex =sll.sll_ifindex;
dest.sll_halen = 6;
memcpy((char*)dest.sll_addr,SendBuffer,6);
if(bind(sock,(struct sockaddr *)(&sll),sizeof(sll))==-1)
{
printf("bind error!!n");
return 0;
}
if(set_promisc("eth0",sock) == -1)
{
printf("BLUE set promisc failed !n");
return 0;
}
printf("nnnn—-send start——n");
print_eth(SendBuffer,64);
sendto(sock,&SendBuffer,64,0,(struct sockaddr *)(&dest),sizeof(dest));
//printf("send to %x:%x:%x:%x:%x:%xn",dest.sll_addr[0],dest.sll_addr[1],dest.sll_addr[2],dest.sll_addr[3],dest.sll_addr[4],dest.sll_addr[5]);
printf("—send success—-n");
return 0;
}
原文件下载: