---
title: "安装osmocom"
author: "tinyhema"
date: "2014-12-05T10:03:48Z"
tags: []
categories: ["开源软件"]
slug: "osmocom"
draft: false
lastmod: "2014-01-07T00:04:39Z"
id: 1999255
url: "https://tinyhema.iteye.com/blog/1999255"
---

安装osmocom

参考：http://drops.wooyun.org/tips/723
http://www.creturn.com/radiowar-%E4%B9%8Bosmocombb-sms-sniffer

**简介**
osmocom是GSM协议栈(Protocols stack)的开源实现，全称是Open source mobile communication Baseband。目的是要实现手机端从物理层(layer1)到layer3的三层实现。

**环境**
基本kali linux，安装过程见上篇 

**安装依赖**

```shell

sudo apt-get install libtool shtool autoconf git-core pkg-config make gcc build-essential libgmp3-dev libmpfr-dev libx11-6 libx11-dev texinfo flex bison libncurses5 libncurses5-dbg libncurses5-dev libncursesw5 libncursesw5-dbg libncursesw5-dev zlibc zlib1g-dev libmpfr4 libmpc-dev 

```


**安装交叉编译环境**
参考：http://bb.osmocom.org/trac/wiki/GnuArmToolchain

交叉编译环境的依赖

```shell

sudo apt-get install build-essential libgmp3-dev libmpfr-dev libx11-6 libx11-dev texinfo flex bison libncurses5 libncurses5-dbg libncurses5-dev libncursesw5 libncursesw5-dbg libncursesw5-dev zlibc zlib1g-dev libmpfr4 libmpc-dev

```


创建文件夹

```shell

mkdir ~/lib/gnuarm
cd ~/lib/gnuarm
mkdir build install src

```


下载build脚本

```shell

wget http://bb.osmocom.org/trac/raw-attachment/wiki/GnuArmToolchain/gnu-arm-build.2.sh
chmod +x gnu-arm-build.2.sh

```


下载相关源代码

```shell

cd src/
wget http://ftp.gnu.org/gnu/gcc/gcc-4.5.2/gcc-4.5.2.tar.bz2
wget http://ftp.gnu.org/gnu/binutils/binutils-2.21.1a.tar.bz2
wget ftp://sources.redhat.com/pub/newlib/newlib-1.19.0.tar.gz

```


开始build
这一步非常耗时，一边去看个电影吧

```shell

cd ..
./gnu-arm-build.2.sh 

```


设置环境变量
~/.bashrc 添加一行

```shell

$vi ~/.bashrc
# 添加下面这一行，记得替换用户名
export PATH=$PATH:/home/${username}/lib/gnuarm/install/bin

$source ~/.bashrc

```


没有设置此环境变量的情况下，编译osmocombb的时候会遇到以下错误

> 
> src/target/firmware/include/asm/swab.h:32: Error: no such instruction: `eor %edx,%ecx,%ecx,ror'
> 


**安装osmocombb、libosmocore**
下载源码

```shell

cd ~
git clone git://git.osmocom.org/osmocom-bb.git  
git clone git://git.osmocom.org/libosmocore.git

```


编译 libosmocore

```shell

cd ~/libosmocore  
autoreconf -i  
./configure  
make  
sudo make install
sudo /sbin/ldconfig

```


编译osmocombb

```shell

cd ~/osmocom-bb  
git checkout --track origin/luca/gsmmap
cd src  
make

```

第一次编译的时候遇到以下错误，原因是最初没有设置gcc交叉编译环境，后来设置交叉编译环境的时候移动了gnuarm的位置，导致的错误，严格按照以上步骤执行即可。

> 
> 报错：没有规则可以创建“apps/hello_world/main.o”需要的目标“/home/${username}/gnuarm/bin/../lib/gcc/arm-elf/3.4.3/../../../../arm-elf/sys-include/sys/types.h” 停止。
> 


finally, done~