Skip to content

Commit 6b791fd

Browse files
committed
Migrate code to C and add workflows
Signed-off-by: Rem01Gaming <[email protected]>
1 parent ff4d274 commit 6b791fd

File tree

13 files changed

+1534
-1284
lines changed

13 files changed

+1534
-1284
lines changed

.github/scripts/compile_deb.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/env bash
2+
3+
if [ -z $GITHUB_WORKSPACE ]; then
4+
echo "This script should only run on GitHub action!" >&2
5+
exit 1
6+
fi
7+
8+
# Make sure we're on right directory
9+
cd $GITHUB_WORKSPACE
10+
11+
out="$GITHUB_WORKSPACE/out"
12+
termux_prefix="/data/data/com.termux/files/usr"
13+
version="$(cat version)"
14+
version_code="$(git rev-list HEAD --count)"
15+
release_code="$(git rev-list HEAD --count)-$(git rev-parse --short HEAD)-release"
16+
deb_name="oneshot-$version-$release_code.deb"
17+
18+
mkdir -v "$out"
19+
mkdir -v "$out/deb"
20+
mkdir -pv "$out/deb$termux_prefix"
21+
mkdir -pv "$out/deb$termux_prefix/share/oneshot"
22+
cp -rv deb/share/* "$out/deb$termux_prefix/share/oneshot"
23+
cp -rv src/libs "$out/deb$termux_prefix/share/oneshot"
24+
cp -rv deb/dpkg-conf "$out/deb/DEBIAN"
25+
chmod -Rv 755 "$out/deb/DEBIAN"
26+
sed -i "s/^Version: .*/Version: $version.$version_code/" ./out/deb/DEBIAN/control
27+
28+
cd $out/deb
29+
dpkg -b . "$GITHUB_WORKSPACE/$deb_name"
30+
echo "$GITHUB_WORKSPACE/$deb_name" >
31+
echo "deb_out=$GITHUB_WORKSPACE/$deb_name"" >>$GITHUB_OUTPUT
32+

.github/scripts/telegram_bot.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/env bash
2+
3+
msg="*$TITLE*
4+
\\#ci\\_$VERSION
5+
\`\`\`
6+
$COMMIT_MESSAGE
7+
\`\`\`
8+
[Commit]($COMMIT_URL)
9+
[Workflow run]($RUN_URL)
10+
"
11+
12+
file="$1"
13+
14+
curl -s -F document=@$file "https://api.telegram.org/bot$BOT_TOKEN/sendDocument" \
15+
-F chat_id="$CHAT_ID" \
16+
-F "disable_web_page_preview=true" \
17+
-F "parse_mode=markdownv2" \
18+
-F caption="$msg"

.github/workflows/pack-deb.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Build DEB Package
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- '.github/workflows/pack-deb.yml'
10+
- 'src/**'
11+
- 'deb/share/**'
12+
- 'deb/dpkg-conf/**'
13+
14+
jobs:
15+
build:
16+
name: Build DEB package
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: NDK Setup
25+
uses: nttld/setup-ndk@v1
26+
with:
27+
ndk-version: r27c
28+
29+
- name: Build Encore JNI
30+
working-directory: ./src
31+
run: ndk-build
32+
33+
- name: dpkg compile
34+
id: compile_deb
35+
working-directory: ./
36+
run: bash .github/scripts/compile_deb.sh
37+
38+
- name: Upload to telegram
39+
env:
40+
CHAT_ID: ${{ secrets.CHAT_ID }}
41+
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
42+
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
43+
COMMIT_URL: ${{ github.event.head_commit.url }}
44+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
45+
TITLE: OneShot Termux DEB Package
46+
run: |
47+
if [ ! -z "${{ secrets.BOT_TOKEN }}" ]; then
48+
export VERSION=$(git rev-list --count HEAD)
49+
bash $GITHUB_WORKSPACE/.github/scripts/telegram_bot.sh ${{ steps.compile_deb.outputs.deb_out }}
50+
fi

Makefile

Lines changed: 0 additions & 40 deletions
This file was deleted.

dpkg-conf/control renamed to deb/dpkg-conf/control

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: oneshot
22
Architecture: all
33
Maintainer: Rem01Gaming
44
Installed-Size: 650
5-
Version: 1.0.1
5+
Version: 1.1.0
66
Homepage: https://github.com/Rem01Gaming/oneshot
7-
Depends: python, pixiewps, wpa-supplicant, tsu, iw
7+
Depends: pixiewps, wpa-supplicant, tsu, iw
88
Description: Run WPS PIN attacks (Pixie Dust and bruteforce) without monitor mode with wpa_supplicant

deb/dpkg-conf/postinst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/data/data/com.termux/files/usr/bin/bash
2+
3+
echo "Creating symlink to oneshot..."
4+
# Create architecture-specific symlinks
5+
arch=$(uname -m)
6+
case $arch in
7+
aarch64) arch_dir="arm64-v8a" ;;
8+
armv7l) arch_dir="armeabi-v7a" ;;
9+
x86_64) arch_dir="x86_64" ;;
10+
i386) arch_dir="x86" ;;
11+
*) echo "Unsupported architecture: $arch" && exit 1 ;;
12+
esac
13+
14+
ln -sf $PREFIX/share/oneshot/libs/$arch_dir/oneshot $PREFIX/bin/oneshot
15+
chmod +x $PREFIX/bin/oneshot
File renamed without changes.

src/.clang-format

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# see https://clang.llvm.org/docs/ClangFormatStyleOptions.html
2+
# Source: https://github.com/martinus/nanobench/blob/master/src/include/.clang-format
3+
---
4+
BasedOnStyle: LLVM
5+
6+
ColumnLimit: 135
7+
AccessModifierOffset: -4
8+
IndentWidth: 4
9+
UseTab: Never
10+
11+
AlignEscapedNewlines: Left
12+
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortLambdasOnASingleLine: Empty
14+
AlwaysBreakTemplateDeclarations: true
15+
BreakConstructorInitializers: BeforeComma
16+
IndentPPDirectives: AfterHash
17+
PointerAlignment: Left

src/jni/Android.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
LOCAL_PATH := $(call my-dir)
2+
3+
include $(CLEAR_VARS)
4+
LOCAL_MODULE := oneshot
5+
LOCAL_SRC_FILES := oneshot.c
6+
LOCAL_LDFLAGS := -static
7+
LOCAL_CFLAGS := -DNDEBUG -O2 -std=c99
8+
include $(BUILD_EXECUTABLE)

src/jni/Application.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
APP_ABI := all
2+
APP_OPTIM := release
3+
APP_PLATFORM := android-29

0 commit comments

Comments
 (0)